src/EventSubscriber/Media/LayoutSubscriber.php line 33

Open in your IDE?
  1. <?php
  2. /*
  3.  * @since 1.0.0
  4.  * @copyright Copyright (C) 2020 ArtMedia. All rights reserved.
  5.  * @website http://artmedia.biz.pl
  6.  * @author Arkadiusz Tobiasz
  7.  * @email kontakt@artmedia.biz.pl
  8.  */
  9. namespace App\EventSubscriber\Media;
  10. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  11. use App\Events\Core\RouteAddEvent;
  12. use Symfony\Contracts\Translation\TranslatorInterface;
  13. class LayoutSubscriber implements EventSubscriberInterface
  14. {
  15.     private $translator;
  16.     public function __construct(
  17.         TranslatorInterface $translator
  18.     ) {
  19.         $this->translator $translator;
  20.     }
  21.     public static function getSubscribedEvents(): array
  22.     {
  23.         return [
  24.             RouteAddEvent::NAME => 'onRouteAddEvent',
  25.         ];
  26.     }
  27.     public function onRouteAddEvent(RouteAddEvent $event): void
  28.     {
  29.         $routes = [
  30.             'photo_upload' => $this->translator->trans('Photo Upload', [], 'media'),
  31.             'album_new' => $this->translator->trans('Create album', [], 'media'),
  32.             'media' => $this->translator->trans('Media list', [], 'media'),
  33.         ];
  34.         foreach ($routes as $route => $label) {
  35.             $event->addRoute($route$label);
  36.         }
  37.     }
  38. }