src/EventSubscriber/Media/SeoSubscriber.php line 34

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\SeoPageAddEvent;
  12. use Symfony\Contracts\Translation\TranslatorInterface;
  13. use App\Model\Core\SeoPage;
  14. class SeoSubscriber implements EventSubscriberInterface
  15. {
  16.     protected $translator;
  17.     public function __construct(
  18.         TranslatorInterface $translator
  19.     ) {
  20.         $this->translator $translator;
  21.     }
  22.     public static function getSubscribedEvents(): array
  23.     {
  24.         return [
  25.             SeoPageAddEvent::NAME => 'onSeoPageAddEvent',
  26.         ];
  27.     }
  28.     public function onSeoPageAddEvent(SeoPageAddEvent $event): void
  29.     {
  30.         $pages = [
  31.             (new SeoPage())->setName($this->translator->trans('Album Page', [], 'admin'))->setRoute('portfolio_album_index')->setParams([
  32.             '%profile%''%album%'
  33.             ]),
  34.             (new SeoPage())->setName($this->translator->trans('Album Page Paginated', [], 'admin'))->setRoute('portfolio_album_index_paginated')->setParams([
  35.             '%profile%''%album%''%page%'
  36.             ]),
  37.             (new SeoPage())->setName($this->translator->trans('Add Profile Album Page', [], 'admin'))->setRoute('portfolio_album_new')->setParams([
  38.             '%profile%'
  39.             ]),
  40.             (new SeoPage())->setName($this->translator->trans('Add Album Page', [], 'admin'))->setRoute('album_new'),
  41.             (new SeoPage())->setName($this->translator->trans('Album Edit Page', [], 'admin'))->setRoute('portfolio_album_edit')->setParams([
  42.             '%profile%''%album%'
  43.             ]),
  44.             (new SeoPage())->setName($this->translator->trans('Album Manage Page', [], 'admin'))->setRoute('portfolio_album_manage')->setParams([
  45.             '%profile%''%album%'
  46.             ]),
  47.             (new SeoPage())->setName($this->translator->trans('Album Credited Manage Page', [], 'admin'))->setRoute('portfolio_credited_manage')->setParams([
  48.             '%profile%',
  49.             ]),
  50.             (new SeoPage())->setName($this->translator->trans('Media List Page', [], 'admin'))->setRoute('media_index'),
  51.             (new SeoPage())->setName($this->translator->trans('Media List Page Paginated', [], 'admin'))->setRoute('media_index_paginated')->setParams([
  52.             '%page%',
  53.             ]),
  54.             (new SeoPage())->setName($this->translator->trans('Media Tag List Page', [], 'admin'))->setRoute('media_tag')->setParams([
  55.             '%tag%',
  56.             ]),
  57.             (new SeoPage())->setName($this->translator->trans('Media Tag List Page Paginated', [], 'admin'))->setRoute('media_tag_paginated')->setParams([
  58.             '%tag%''%page%',
  59.             ]),
  60.             (new SeoPage())->setName($this->translator->trans('Photos Manage Page', [], 'admin'))->setRoute('portfolio_photo_index')->setParams([
  61.             '%profile%',
  62.             ]),
  63.             (new SeoPage())->setName($this->translator->trans('Photos Manage Page Paginated', [], 'admin'))->setRoute('portfolio_photo_paginated')->setParams([
  64.             '%profile%''%page%'
  65.             ]),
  66.             (new SeoPage())->setName($this->translator->trans('Edit Photo Page', [], 'admin'))->setRoute('portfolio_photo_edit')->setParams([
  67.             '%profile%',
  68.             ]),
  69.             (new SeoPage())->setName($this->translator->trans('Edit Credited Photo Page', [], 'admin'))->setRoute('portfolio_photo_credited')->setParams([
  70.             '%profile%',
  71.             ]),
  72.             (new SeoPage())->setName($this->translator->trans('Upload Profile Photo Page', [], 'admin'))->setRoute('portfolio_photo_upload')->setParams([
  73.             '%profile%',
  74.             ]),
  75.             (new SeoPage())->setName($this->translator->trans('Upload Photo Page', [], 'admin'))->setRoute('photo_upload'),
  76.             (new SeoPage())->setName($this->translator->trans('Upload Profile Photo Page', [], 'admin'))->setRoute('portfolio_photo_upload')->setParams([
  77.             '%profile%',
  78.             ]),
  79.             (new SeoPage())->setName($this->translator->trans('Portfolio Page', [], 'admin'))->setRoute('portfolio')->setParams([
  80.             '%profile%',
  81.             ]),
  82.             (new SeoPage())->setName($this->translator->trans('Portfolio Album View Page', [], 'admin'))->setRoute('portfolio_album')->setParams([
  83.             '%profile%''%album%',
  84.             ]),
  85.             (new SeoPage())->setName($this->translator->trans('Portfolio Credited Album View Page', [], 'admin'))->setRoute('portfolio_credited')->setParams([
  86.             '%profile%',
  87.             ]),
  88.             (new SeoPage())->setName($this->translator->trans('Photo View Page', [], 'admin'))->setRoute('portfolio_photo')->setParams([
  89.             '%profile%',
  90.             ]),
  91.         ];
  92.         foreach ($pages as $page) {
  93.             $event->addPage($page);
  94.         }
  95.     }
  96. }