mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 06:01:35 +01:00
Implemented different formats
This commit is contained in:
parent
3bf84d3ec8
commit
1915c77d8c
@ -6,6 +6,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use App\Event\Menu\Topbar\SourceMenuEvent;
|
||||
use Knp\Menu\ItemInterface;
|
||||
|
||||
class SourceMenuSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
@ -30,16 +31,48 @@ class SourceMenuSubscriber implements EventSubscriberInterface
|
||||
$menu = $event->getItem();
|
||||
$menu->addChild($this->translator->trans('edit'), [
|
||||
'route' => 'app_source_edit',
|
||||
'routeParameters' => ['id' => $event->getRequest()->getCurrentRequest()->attributes->get('id')],
|
||||
'routeParameters' => [
|
||||
'id' => $event->getRequest()->getCurrentRequest()->attributes->get('id'),
|
||||
],
|
||||
'attributes' => [
|
||||
'icon' => 'fas fa-edit',
|
||||
],
|
||||
]);
|
||||
$menu->addChild($this->translator->trans('show'), [
|
||||
'route' => 'app_source_show',
|
||||
'routeParameters' => ['id' => $event->getRequest()->getCurrentRequest()->attributes->get('id')],
|
||||
$this->generateSourceFormatDropdown($menu, $event);
|
||||
}
|
||||
|
||||
private function generateSourceFormatDropdown(ItemInterface $menu, SourceMenuEvent $event): void
|
||||
{
|
||||
$dropdown = $menu->addChild($this->translator->trans('show'), [
|
||||
'attributes' => [
|
||||
'icon' => 'fas fa-eye',
|
||||
'dropdown' => 'true',
|
||||
],
|
||||
]);
|
||||
foreach ([
|
||||
'html',
|
||||
'json',
|
||||
'xml',
|
||||
] as $format) {
|
||||
$dropdown->addChild($format, [
|
||||
'route' => 'app_source_show',
|
||||
'routeParameters' => [
|
||||
'id' => $event->getRequest()->getCurrentRequest()->attributes->get('id'),
|
||||
'_format' => $format,
|
||||
],
|
||||
'attributes' => [
|
||||
'icon' => 'fas fa-sign-out-alt',
|
||||
'divider_append' => true,
|
||||
],
|
||||
]);
|
||||
}
|
||||
$dropdown->addChild($this->translator->trans('standard'), [
|
||||
'route' => 'app_source_show',
|
||||
'routeParameters' => [
|
||||
'id' => $event->getRequest()->getCurrentRequest()->attributes->get('id'),
|
||||
],
|
||||
'attributes' => [
|
||||
'icon' => 'fas fa-sign-out-alt',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user