function file_field_widget_uri

Determines the URI for a file field instance.

Parameters

$field: A field array.

$instance: A field instance array.

$data: An array of token objects to pass to \Drupal\Core\Utility\Token::replace().

Return value

A file directory URI with tokens replaced.

See also

\Drupal\Core\Utility\Token::replace()

1 call to file_field_widget_uri()
FileWidget::formElement in drupal/core/modules/file/lib/Drupal/file/Plugin/field/widget/FileWidget.php
Implements \Drupal\field\Plugin\Type\Widget\WidgetInterface::formElement().

File

drupal/core/modules/file/file.field.inc, line 363
Field module functionality for the File module.

Code

function file_field_widget_uri($field, $instance, $data = array()) {
  $destination = trim($instance['settings']['file_directory'], '/');

  // Replace tokens.
  $destination = Drupal::token()
    ->replace($destination, $data);
  return $field['settings']['uri_scheme'] . '://' . $destination;
}