protected function File::renderLink in Drupal 9
Same name and namespace in other branches
- 8 core/modules/file/src/Plugin/views/field/File.php \Drupal\file\Plugin\views\field\File::renderLink()
- 10 core/modules/file/src/Plugin/views/field/File.php \Drupal\file\Plugin\views\field\File::renderLink()
Prepares link to the file.
Parameters
string $data: The XSS safe string for the link text.
\Drupal\views\ResultRow $values: The values retrieved from a single row of a view's query result.
Return value
string Returns a string for the link text.
1 call to File::renderLink()
- File::render in core/
modules/ file/ src/ Plugin/ views/ field/ File.php - Renders the field.
File
- core/
modules/ file/ src/ Plugin/ views/ field/ File.php, line 101
Class
- File
- Field handler to provide simple renderer that allows linking to a file.
Namespace
Drupal\file\Plugin\views\fieldCode
protected function renderLink($data, ResultRow $values) {
if (!empty($this->options['link_to_file']) && $data !== NULL && $data !== '') {
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['url'] = $this->fileUrlGenerator
->generate($this
->getValue($values, 'uri'));
}
return $data;
}