vendor/ibexa/workflow/src/bundle/Menu/ConfigureMainMenuListener.php line 36

Open in your IDE?
  1. <?php
  2. /**
  3.  * @copyright Copyright (C) Ibexa AS. All rights reserved.
  4.  * @license For full copyright and license information view LICENSE file distributed with this source code.
  5.  */
  6. declare(strict_types=1);
  7. namespace Ibexa\Bundle\Workflow\Menu;
  8. use Ibexa\AdminUi\Menu\Event\ConfigureMenuEvent;
  9. use Ibexa\AdminUi\Menu\MainMenuBuilder;
  10. use Ibexa\AdminUi\Menu\MenuItemFactory;
  11. use JMS\TranslationBundle\Model\Message;
  12. use JMS\TranslationBundle\Translation\TranslationContainerInterface;
  13. class ConfigureMainMenuListener implements TranslationContainerInterface
  14. {
  15.     public const ITEM_ADMIN__WORKFLOW 'main__admin__workflow';
  16.     /** @var \Ibexa\AdminUi\Menu\MenuItemFactory */
  17.     private $menuItemFactory;
  18.     /**
  19.      * @param \Ibexa\AdminUi\Menu\MenuItemFactory $menuItemFactory
  20.      */
  21.     public function __construct(
  22.         MenuItemFactory $menuItemFactory
  23.     ) {
  24.         $this->menuItemFactory $menuItemFactory;
  25.     }
  26.     /**
  27.      * @param \Ibexa\AdminUi\Menu\Event\ConfigureMenuEvent $event
  28.      */
  29.     public function onMenuConfigure(ConfigureMenuEvent $event): void
  30.     {
  31.         $menu $event->getMenu();
  32.         if (!$adminMenu $menu->getChild(MainMenuBuilder::ITEM_ADMIN)) {
  33.             return;
  34.         }
  35.         $adminMenu->addChild($this->menuItemFactory->createItem(
  36.             self::ITEM_ADMIN__WORKFLOW,
  37.             [
  38.                 'route' => 'ibexa.workflow.list',
  39.                 'extras' => [
  40.                     'routes' => [
  41.                         'view' => 'ibexa.workflow.view',
  42.                     ],
  43.                     'orderNumber' => 30,
  44.                 ],
  45.             ]
  46.         ));
  47.     }
  48.     /**
  49.      * {@inheritdoc}
  50.      */
  51.     public static function getTranslationMessages(): array
  52.     {
  53.         return [
  54.             (new Message(self::ITEM_ADMIN__WORKFLOW'ibexa_menu'))->setDesc('Workflow'),
  55.         ];
  56.     }
  57. }
  58. class_alias(ConfigureMainMenuListener::class, 'EzSystems\EzPlatformWorkflowBundle\Menu\ConfigureMainMenuListener');