The breadcrumb maps a list of route to a list of link.
You don't need to build a new EventListener/EventSubscriber as long as you've already made it with the Sidebar Navigation component. If it fits your needs, you can re-use this class to build the Breadcrumb list of links.
Edit the previously made class MenuBuilderSubscriber
and register it for another event:
<?php
// src/EventSubscriber/MenuBuilderSubscriber.php
namespace App\EventSubscriber;
use KevinPapst\AdminLTEBundle\Event\BreadcrumbMenuEvent;
use KevinPapst\AdminLTEBundle\Event\SidebarMenuEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class MenuBuilderSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
SidebarMenuEvent::class => ['onSetupMenu', 100],
BreadcrumbMenuEvent::class => ['onSetupNavbar', 100],
];
}
// ... the rest of the class follows here ...
}
If you are using an EventListener, you have to register it as new listener to the event system.
# config/services.yaml
services:
app.breadcrumb_listener:
class: App\EventListener\MenuBuilderListener
tags:
- { name: kernel.event_listener, event: theme.breadcrumb, method: onSetupMenu }
As you can see we are using the menu listener from the Sidebar Navigation
but attaching to the theme.breadcrumb
event.
You don't have to care about translating your breadcrumb, each item will be automatically displayed by applying the |trans
filter.
We apply the same principle like we do in the Sidebar Navigation.
Please go back to the AdminLTE bundle documentation to find out more about using the theme.