custom/plugins/MojeBambinoPopup/src/Subscriber/FooterPageletSubscriber.php line 28

Open in your IDE?
  1. <?php
  2. namespace MojeBambino\Popup\Subscriber;
  3. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  4. use Shopware\Storefront\Pagelet\Footer\FooterPageletLoadedEvent;
  5. use MojeBambino\Popup\Struct\Baner;
  6. use MojeBambino\Popup\Entity\PopupEntity;
  7. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
  8. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  9. class FooterPageletSubscriber implements EventSubscriberInterface
  10. {
  11.     protected EntityRepositoryInterface $popupRepository;
  12.     
  13.     public function __construct(EntityRepositoryInterface $popupRepository){
  14.         $this->popupRepository $popupRepository;
  15.     }
  16.     
  17.     public static function getSubscribedEvents(): array
  18.     {
  19.         return [
  20.                 FooterPageletLoadedEvent::class => 'addFooterBaner',
  21.         ];
  22.     }
  23.     
  24.     public function addFooterBaner(FooterPageletLoadedEvent $event): void
  25.     {
  26.         $baner = new Baner();
  27.         
  28.         $criteria = new Criteria();
  29.         $dupa $this->popupRepository->search($criteria$event->getContext());
  30.         $baner->setBaner($dupa->getElements()); //zwraca tablicę obiektów, czyli w tym przypadku w tablicy jest jeden obiekt z obrazkiem
  31.         
  32.         $event->getPagelet()->addExtension('footer_baner'$baner);
  33.     }
  34. }