function File::__construct

Same name in other branches
  1. 10 core/modules/file/src/Plugin/views/field/File.php \Drupal\file\Plugin\views\field\File::__construct()
  2. 11.x core/modules/file/src/Plugin/views/field/File.php \Drupal\file\Plugin\views\field\File::__construct()

Constructs a File object.

Parameters

array $configuration: A configuration array containing information about the plugin instance.

string $plugin_id: The plugin_id for the plugin instance.

mixed $plugin_definition: The plugin implementation definition.

\Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator: The file URL generator.

Overrides HandlerBase::__construct

File

core/modules/file/src/Plugin/views/field/File.php, line 41

Class

File
Field handler to provide simple renderer that allows linking to a file.

Namespace

Drupal\file\Plugin\views\field

Code

public function __construct(array $configuration, $plugin_id, $plugin_definition, FileUrlGeneratorInterface $file_url_generator = NULL) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    if (!$file_url_generator) {
        @trigger_error('Calling File::__construct() without the $file_url_generator argument is deprecated in drupal:9.3.0 and the $file_url_generator argument will be required in drupal:10.0.0. See https://www.drupal.org/node/2940031', E_USER_DEPRECATED);
        $file_url_generator = \Drupal::service('file_url_generator');
    }
    $this->fileUrlGenerator = $file_url_generator;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.