custom/plugins/DreiscSeoPro/src/Subscriber/Installment/BaseInformation/BaseInformationSubscriber.php line 27

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace DreiscSeoPro\Subscriber\Installment\BaseInformation;
  3. use Shopware\Core\Framework\DataAbstractionLayer\Exception\InconsistentCriteriaIdsException;
  4. use Shopware\Storefront\Page\Navigation\NavigationPageLoadedEvent;
  5. use Shopware\Storefront\Page\Page;
  6. use Shopware\Storefront\Page\PageLoadedEvent;
  7. use Shopware\Storefront\Page\Product\ProductPage;
  8. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  9. class BaseInformationSubscriber implements EventSubscriberInterface
  10. {
  11.     public const DREISC_SEO_INSTALLMENT_BASE_INFORMATION_DATA 'dreiscSeoInstallmentBaseInformationData';
  12.     public static function getSubscribedEvents()
  13.     {
  14.         return [
  15.             NavigationPageLoadedEvent::class => 'addInstallment',
  16.         ];
  17.     }
  18.     /**
  19.      * @param PageLoadedEvent $event
  20.      * @throws InconsistentCriteriaIdsException
  21.      */
  22.     public function addInstallment(PageLoadedEvent $event)
  23.     {
  24.         /** @var Page|ProductPage $page */
  25.         $page $event->getPage();
  26.         $baseInformationDataStruct = new BaseInformationDataStruct(
  27.             $event->getRequest()->attributes->get('navigationId')
  28.         );
  29.         $page->addExtension(
  30.             self::DREISC_SEO_INSTALLMENT_BASE_INFORMATION_DATA,
  31.             $baseInformationDataStruct
  32.         );
  33.     }
  34. }