custom/plugins/UandiEfbErpSynchronization/src/Subscriber/AccountMenuSubscriber.php line 25

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Uandi\UandiEfbErpSynchronization\Subscriber;
  3. use Shopware\Core\Framework\Struct\ArrayStruct;
  4. use Shopware\Storefront\Page\GenericPageLoadedEvent;
  5. use Shopware\Storefront\Page\PageLoadedEvent;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. use Uandi\UandiEfbErpSynchronization\Service\Document\Lists\ListingServiceFactory;
  8. class AccountMenuSubscriber implements EventSubscriberInterface
  9. {
  10.     private ListingServiceFactory $listingServiceFactory;
  11.     public static function getSubscribedEvents(): array
  12.     {
  13.         return [GenericPageLoadedEvent::class => 'addAvailableErpDocumentTypes'];
  14.     }
  15.     public function __construct(ListingServiceFactory $listingServiceFactory)
  16.     {
  17.         $this->listingServiceFactory $listingServiceFactory;
  18.     }
  19.     public function addAvailableErpDocumentTypes(PageLoadedEvent $event): void
  20.     {
  21.         if (null === $event->getSalesChannelContext()->getCustomer()) {
  22.             return;
  23.         }
  24.         $event->getPage()->addExtension(
  25.             'availableErpDocumentTypes',
  26.             new ArrayStruct($this->listingServiceFactory->getAvailableTypes())
  27.         );
  28.     }
  29. }