protected function DisplayFileList::makeLink in Filebrowser 8.2
Same name and namespace in other branches
- 3.x src/File/DisplayFileList.php \Drupal\filebrowser\File\DisplayFileList::makeLink()
Creates links for the file list
Parameters
DisplayFile $file:
int $fid:
string $fragment:
for file: 'http://drupal.dev/filebrowser/download/4' for folder: 'http://drupal.dev/node/1?fid=23#fragment
Return value
1 call to DisplayFileList::makeLink()
- DisplayFileList::dbSync in src/
File/ DisplayFileList.php - Synchronizes what we seen on filesystem with what is stored in database We also build an access URL (link) for each file as it is why we stored this stuff in DB (have a unique ID for each file and path) to get rid of national character mess in URLS.
File
- src/
File/ DisplayFileList.php, line 339
Class
- DisplayFileList
- Class FileDisplayList @package Drupal\filebrowser This class holds the list of files to be displayed on the filebrowser node. These files are retrieved from the filesystem and filtered for user and node access. The array produced by this class…
Namespace
Drupal\filebrowser\FileCode
protected function makeLink(DisplayFile $file, $fid = null, $fragment = null) {
$options = [
'query' => [
'fid' => $fid,
],
];
if (isset($fragment)) {
$options['fragment'] = $fragment;
}
if ($file->displayName == '..') {
$display_name = $this
->t('Go up');
return Link::createFromRoute($display_name, 'entity.node.canonical', [
'node' => $this->node
->id(),
], $options);
}
$name = $this->filebrowser->hideExtension ? pathinfo($file->displayName, PATHINFO_FILENAME) : $file->displayName;
if ($file->fileData->type != 'file') {
return Link::createFromRoute($name, 'entity.node.canonical', [
'node' => $this->node
->id(),
], $options);
}
else {
return Link::createFromRoute($name, 'filebrowser.page_download', [
'fid' => $fid,
]);
}
}