protected function FileName::renderLink in File Entity (fieldable files) 8.2
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 FileName::renderLink()
- FileName::render in src/
Plugin/ views/ field/ FileName.php - Render the field.
File
- src/
Plugin/ views/ field/ FileName.php, line 66
Class
- FileName
- Field handler to provide simple renderer that allows linking to a file.
Namespace
Drupal\file_entity\Plugin\views\fieldCode
protected function renderLink($data, ResultRow $values) {
if (!empty($this->options['link_to_file']) && !empty($this->additional_fields['fid'])) {
if ($data !== NULL && $data !== '') {
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['url'] = Url::fromRoute('entity.file.canonical', [
'file' => $this
->getValue($values, 'fid'),
]);
}
else {
$this->options['alter']['make_link'] = FALSE;
}
}
return $data;
}