function File::renderLink
Same name in other branches
- 8.9.x 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()
- 11.x 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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.