vendor/ezsystems/ezplatform-user/src/lib/EventListener/UserPasswordChangeRightSidebarListener.php line 33

Open in your IDE?
  1. <?php
  2. /**
  3.  * @copyright Copyright (C) eZ Systems 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 EzSystems\EzPlatformUser\EventListener;
  8. use EzSystems\EzPlatformAdminUi\Menu\Event\ConfigureMenuEvent;
  9. use JMS\TranslationBundle\Translation\TranslationContainerInterface;
  10. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  11. use JMS\TranslationBundle\Model\Message;
  12. class UserPasswordChangeRightSidebarListener implements EventSubscriberInterfaceTranslationContainerInterface
  13. {
  14.     /* Menu items */
  15.     public const ITEM__UPDATE 'user_password_change__sidebar_right__update';
  16.     public const ITEM__CANCEL 'user_password_change__sidebar_right__cancel';
  17.     /**
  18.      * @return array
  19.      */
  20.     public static function getSubscribedEvents(): array
  21.     {
  22.         return [ConfigureMenuEvent::USER_PASSWORD_CHANGE_SIDEBAR_RIGHT => 'onUserPasswordChangeRightSidebarConfigure'];
  23.     }
  24.     /**
  25.      * @param \EzSystems\EzPlatformAdminUi\Menu\Event\ConfigureMenuEvent $event
  26.      */
  27.     public function onUserPasswordChangeRightSidebarConfigure(ConfigureMenuEvent $event): void
  28.     {
  29.         $menu $event->getMenu();
  30.         $menu->addChild(
  31.             self::ITEM__UPDATE,
  32.             [
  33.                 'attributes' => [
  34.                     'class' => 'btn--trigger',
  35.                     'data-click' => '#user_password_change_change',
  36.                 ],
  37.                 'extras' => ['icon' => 'publish''translation_domain' => 'menu'],
  38.             ]
  39.         );
  40.         $menu->addChild(
  41.             self::ITEM__CANCEL,
  42.             [
  43.                 'route' => 'ezplatform.dashboard',
  44.                 'extras' => ['icon' => 'circle-close''translation_domain' => 'menu'],
  45.             ]
  46.         );
  47.     }
  48.     /**
  49.      * @return \JMS\TranslationBundle\Model\Message[]
  50.      */
  51.     public static function getTranslationMessages(): array
  52.     {
  53.         return [
  54.             (new Message(self::ITEM__UPDATE'menu'))->setDesc('Update'),
  55.             (new Message(self::ITEM__CANCEL'menu'))->setDesc('Discard changes'),
  56.         ];
  57.     }
  58. }