mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-10-31 01:09:41 +00:00 
			
		
		
		
	Implemented different formats
This commit is contained in:
		| @@ -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', | ||||
|             ], | ||||
|         ]); | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user