vendor/ibexa/dashboard/src/lib/EventSubscriber/MainMenuSubscriber.php line 29

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\Dashboard\EventSubscriber;
  8. use Ibexa\AdminUi\Menu\Event\ConfigureMenuEvent;
  9. use Ibexa\AdminUi\Menu\MainMenuBuilder;
  10. use JMS\TranslationBundle\Model\Message;
  11. use JMS\TranslationBundle\Translation\TranslationContainerInterface;
  12. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  13. final class MainMenuSubscriber implements EventSubscriberInterfaceTranslationContainerInterface
  14. {
  15.     // Main Menu / Dashboard
  16.     public const ITEM_CUSTOMIZABLE_DASHBOARD 'main__customizable_dashboard';
  17.     public static function getSubscribedEvents(): array
  18.     {
  19.         return [
  20.             ConfigureMenuEvent::MAIN_MENU => ['onConfigureMainMenu'],
  21.         ];
  22.     }
  23.     public function onConfigureMainMenu(ConfigureMenuEvent $event): void
  24.     {
  25.         $menu $event->getMenu();
  26.         $menu->addChild(
  27.             self::ITEM_CUSTOMIZABLE_DASHBOARD,
  28.             [
  29.                 'route' => 'ibexa.dashboard',
  30.                 'attributes' => [
  31.                     'data-tooltip-placement' => 'right',
  32.                     'data-tooltip-extra-class' => 'ibexa-tooltip--navigation',
  33.                 ],
  34.                 'extras' => [
  35.                     'icon' => 'home-page',
  36.                     'orderNumber' => 0,
  37.                 ],
  38.             ]
  39.         );
  40.         $contentMenu $menu->getChild(MainMenuBuilder::ITEM_CONTENT);
  41.         if ($contentMenu !== null) {
  42.             $contentMenu->removeChild(MainMenuBuilder::ITEM_DASHBOARD);
  43.         }
  44.     }
  45.     public static function getTranslationMessages(): array
  46.     {
  47.         return [
  48.             (new Message(self::ITEM_CUSTOMIZABLE_DASHBOARD'ibexa_menu'))->setDesc('Dashboard'),
  49.         ];
  50.     }
  51. }