forked from kevinpapst/AdminLTEBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBreadcrumbController.php
More file actions
59 lines (51 loc) · 1.81 KB
/
BreadcrumbController.php
File metadata and controls
59 lines (51 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/*
* This file is part of the AdminLTE bundle.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace KevinPapst\AdminLTEBundle\Controller;
use KevinPapst\AdminLTEBundle\Event\BreadcrumbMenuEvent;
use KevinPapst\AdminLTEBundle\Event\SidebarMenuEvent;
use KevinPapst\AdminLTEBundle\Model\MenuItemInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* Controller to handle breadcrumb display inside the layout
*/
class BreadcrumbController extends EmitterController
{
/**
* Controller Reference action to be called inside the layout.
*
* Triggers the {@link BreadcrumbMenuEvent} to receive the currently active menu chain.
*
* If there are no listeners attached for this event, the return value is an empty response.
*
* @param Request $request
* @return Response
*/
public function breadcrumbAction(Request $request): Response
{
@trigger_error('BreadcrumbController::breadcrumbAction() is deprecated and will be removed with 4.0', E_USER_DEPRECATED);
if (!$this->hasListener(BreadcrumbMenuEvent::class)) {
return new Response();
}
/** @var SidebarMenuEvent $event */
$event = $this->dispatch(new BreadcrumbMenuEvent($request));
/** @var MenuItemInterface $active */
$active = $event->getActive();
$list = [];
if (null !== $active) {
$list[] = $active;
while (null !== ($item = $active->getActiveChild())) {
$list[] = $item;
$active = $item;
}
}
return $this->render('@AdminLTE/Breadcrumb/breadcrumb.html.twig', [
'active' => $list,
]);
}
}