request->getParam('controller');
$action = $this->request->getParam('action');
$curentPath = "{$controller}{$action}";
$entity = !empty($entity) ? $entity : [];
$breadcrumbLinks = '';
$breadcrumbAction = '';
$this->Breadcrumbs->setTemplates([
'wrapper' => sprintf(
''
),
'item' => '
{{separator}}',
'itemWithoutLink' => '{{separator}}',
'separator' => ''
]);
if (!empty($breadcrumb)) {
foreach ($breadcrumb as $i => $entry) {
if (!empty($entry['textGetter'])) {
if (is_array($entry['textGetter']) && !empty($entry['textGetter']['path'])) {
$data = !empty(${$entry['textGetter']['varname']}) ? ${$entry['textGetter']['varname']} : $entity;
$entry['label'] = Cake\Utility\Hash::get($data, $entry['textGetter']['path']);
} else {
$entry['label'] = Cake\Utility\Hash::get($entity, $entry['textGetter']);
}
}
if (empty($entry['label'])) {
$entry['label'] = "[{$entry['textGetter']}]";
}
if (!empty($entry['url_vars'])) {
$entry['url'] = $this->DataFromPath->buildStringFromDataPath($entry['url'], $entity, $entry['url_vars']);
}
$this->Breadcrumbs->add(h($entry['label']), Router::url($entry['url']), [
'title' => h($entry['label']),
'templateVars' => [
'linkClass' => $i == 0 ? 'fw-light' : '',
'icon' => ($i == 0 && !empty($entry['icon'])) ? $this->FontAwesome->getClass(h($entry['icon'])) : ''
]
]);
}
$lastCrumb = $breadcrumb[count($breadcrumb) - 1];
if (!empty($lastCrumb['links'])) {
// dd($lastCrumb['links']);
foreach ($lastCrumb['links'] as $i => $linkEntry) {
if (empty($linkEntry['route_path'])) {
$active = false;
} else {
$active = $linkEntry['route_path'] == $lastCrumb['route_path'];
}
if (!empty($linkEntry['url_vars'])) {
$linkEntry['url'] = $this->DataFromPath->buildStringFromDataPath($linkEntry['url'], $entity, $linkEntry['url_vars']);
}
if (!empty($linkEntry['selfLink'])) {
$url = Router::url(null);
} else {
$url = Router::url($linkEntry['url']);
}
$breadcrumbLinks .= sprintf(
'%s',
$active ? 'secondary' : 'outline-secondary',
$url,
h($linkEntry['label'])
);
}
}
$badgeNumber = 0;
if (!empty($lastCrumb['actions'])) {
foreach ($lastCrumb['actions'] as $i => $actionEntry) {
if (!empty($actionEntry['url_vars'])) {
$actionEntry['url'] = $this->DataFromPath->buildStringFromDataPath($actionEntry['url'], $entity, $actionEntry['url_vars']);
}
if (!empty($actionEntry['badge'])) {
$badgeNumber += 1;
}
if (!empty($actionEntry['isPOST'])) {
$onclickFunction = sprintf('UI.overlayUntilResolve(this, UI.submissionModalAutoGuess(\'%s\'))', h(Router::url($actionEntry['url'])));
} else if (!empty($actionEntry['isRedirect'])) {
$onclickFunction = sprintf('window.location.replace(\'%s\');', h(Router::url($actionEntry['url'])));
} else {
$onclickFunction = sprintf('UI.overlayUntilResolve(this, UI.modalFromUrl(\'%s\'))', h(Router::url($actionEntry['url'])));
}
$breadcrumbAction .= sprintf(
'%s%s',
!empty($actionEntry['variant']) ? sprintf('dropdown-item-%s', $actionEntry['variant']) : '',
$onclickFunction,
!empty($actionEntry['icon']) ? $this->FontAwesome->getClass(h($actionEntry['icon'])) : '',
h($actionEntry['label']),
!empty($actionEntry['badge']) ? $this->Bootstrap->badge($actionEntry['badge']) : ''
);
}
}
}
?>
Breadcrumbs->render(
[],
['separator' => '']
);
?>