private function BreadcrumbBuilder::buildLinks in Filebrowser 8.2
Same name and namespace in other branches
- 3.x src/Breadcrumb/BreadcrumbBuilder.php \Drupal\filebrowser\Breadcrumb\BreadcrumbBuilder::buildLinks()
Creates the filebrowser breadcrumb links
Parameters
string $title:
int $fid id of current folder being viewed:
array $content array from the DB containing all paths (folders) keyed by $fid.:
Return value
array
1 call to BreadcrumbBuilder::buildLinks()
- BreadcrumbBuilder::build in src/
Breadcrumb/ BreadcrumbBuilder.php - @inheritdoc
File
- src/
Breadcrumb/ BreadcrumbBuilder.php, line 76
Class
Namespace
Drupal\filebrowser\BreadcrumbCode
private function buildLinks($title, $content, $fid) {
$links[0] = Link::createFromRoute($this
->t('Home'), '<front>');
$links[1] = Link::createFromRoute($title, 'entity.node.canonical', [
'node' => $this->node
->id(),
]);
$trail = isset($fid) && isset($content[$fid]) ? ltrim($content[$fid]->path, "/") : null;
$folders_raw = !is_null($trail) ? explode('/', $trail) : null;
if (!empty($folders_raw)) {
// process the folder to set the fid
$folders = $this
->processTrail($folders_raw, $content);
$count = count($folders) + 1;
for ($i = 2; $i <= $count; $i++) {
if ($i < $count) {
$links[$i] = Link::fromTextAndUrl($folders[$i - 2]['title'], Url::fromUserInput('/node'));
$links[$i] = Link::fromTextAndUrl($folders[$i - 2]['title'], Url::fromRoute('entity.node.canonical', [
'node' => $this->node
->id(),
], [
'query' => [
'fid' => $folders[$i - 2]['fid'],
],
]));
}
else {
$links[$i] = Link::createFromRoute($folders[$i - 2]['title'], '<none>');
}
}
}
else {
// there are no subdirectories so [1] is the last item
// route the link to <none>
$links[1] = Link::createFromRoute($title, '<none>');
}
return $links;
}