vendor/ibexa/admin-ui/src/lib/EventListener/UserPasswordChangeRightSidebarListener.php line 42

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\AdminUi\EventListener;
  8. use Ibexa\AdminUi\Menu\Event\ConfigureMenuEvent;
  9. use JMS\TranslationBundle\Model\Message;
  10. use JMS\TranslationBundle\Translation\TranslationContainerInterface;
  11. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  12. use Symfony\Contracts\Translation\TranslatorInterface;
  13. class UserPasswordChangeRightSidebarListener implements EventSubscriberInterfaceTranslationContainerInterface
  14. {
  15.     /* Menu items */
  16.     public const ITEM__UPDATE 'user_password_change__sidebar_right__update';
  17.     public const ITEM__CANCEL 'user_password_change__sidebar_right__cancel';
  18.     /** @var \Symfony\Contracts\Translation\TranslatorInterface */
  19.     private $translator;
  20.     public function __construct(TranslatorInterface $translator)
  21.     {
  22.         $this->translator $translator;
  23.     }
  24.     /**
  25.      * @return array
  26.      */
  27.     public static function getSubscribedEvents(): array
  28.     {
  29.         return [ConfigureMenuEvent::USER_PASSWORD_CHANGE_SIDEBAR_RIGHT => 'onUserPasswordChangeRightSidebarConfigure'];
  30.     }
  31.     /**
  32.      * @param \Ibexa\AdminUi\Menu\Event\ConfigureMenuEvent $event
  33.      */
  34.     public function onUserPasswordChangeRightSidebarConfigure(ConfigureMenuEvent $event): void
  35.     {
  36.         $menu $event->getMenu();
  37.         $menu->addChild(
  38.             self::ITEM__UPDATE,
  39.             [
  40.                 'attributes' => [
  41.                     'class' => 'ibexa-btn--trigger',
  42.                     'data-click' => '#user_password_change_change',
  43.                 ],
  44.                 'extras' => ['translation_domain' => 'ibexa_menu'],
  45.             ]
  46.         );
  47.         $menu->addChild(
  48.             self::ITEM__CANCEL,
  49.             [
  50.                 'extras' => ['translation_domain' => 'ibexa_menu'],
  51.                 'route' => 'ibexa.user_settings.list',
  52.                 'routeParameters' => [
  53.                     '_fragment' => 'ibexa-tab-my-account-settings',
  54.                 ],
  55.             ]
  56.         );
  57.     }
  58.     /**
  59.      * @return \JMS\TranslationBundle\Model\Message[]
  60.      */
  61.     public static function getTranslationMessages(): array
  62.     {
  63.         return [
  64.             (new Message(self::ITEM__UPDATE'ibexa_menu'))->setDesc('Save and close'),
  65.             (new Message(self::ITEM__CANCEL'ibexa_menu'))->setDesc('Discard'),
  66.         ];
  67.     }
  68. }
  69. class_alias(UserPasswordChangeRightSidebarListener::class, 'EzSystems\EzPlatformAdminUi\EventListener\UserPasswordChangeRightSidebarListener');