<?php
/*
* @since 1.0.0
* @copyright Copyright (C) 2020 ArtMedia. All rights reserved.
* @website http://artmedia.biz.pl
* @author Arkadiusz Tobiasz
* @email kontakt@artmedia.biz.pl
*/
namespace App\EventSubscriber\Media;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use App\Events\Core\RouteAddEvent;
use Symfony\Contracts\Translation\TranslatorInterface;
class LayoutSubscriber implements EventSubscriberInterface
{
private $translator;
public function __construct(
TranslatorInterface $translator
) {
$this->translator = $translator;
}
public static function getSubscribedEvents(): array
{
return [
RouteAddEvent::NAME => 'onRouteAddEvent',
];
}
public function onRouteAddEvent(RouteAddEvent $event): void
{
$routes = [
'photo_upload' => $this->translator->trans('Photo Upload', [], 'media'),
'album_new' => $this->translator->trans('Create album', [], 'media'),
'media' => $this->translator->trans('Media list', [], 'media'),
];
foreach ($routes as $route => $label) {
$event->addRoute($route, $label);
}
}
}