vendor/nellapp/sdk-bundle/src/Channel/EventSubscriber/ChannelMenuDisplayedSubscriber.php line 30

Open in your IDE?
  1. <?php
  2. namespace Nellapp\Bundle\SDKBundle\Channel\EventSubscriber;
  3. use Nellapp\Bundle\SDKBundle\Permission\Event\ChannelMenuDisplayedEvent;
  4. use Nellapp\Bundle\SDKBundle\Sync\ApiClient\ChannelUserData\ChannelUserDataClient;
  5. use Psr\Log\LoggerInterface;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
  8. use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
  9. use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
  10. use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
  11. class ChannelMenuDisplayedSubscriber implements EventSubscriberInterface
  12. {
  13.     public function __construct(
  14.         private ChannelUserDataClient $channelUserDataClient,
  15.         private LoggerInterface       $logger,
  16.     )
  17.     {
  18.     }
  19.     public static function getSubscribedEvents(): array
  20.     {
  21.         return [
  22.             ChannelMenuDisplayedEvent::class => '__invoke',
  23.         ];
  24.     }
  25.     public function __invoke(ChannelMenuDisplayedEvent $event): void
  26.     {
  27.         try {
  28.             $this->channelUserDataClient->patchMenuDisplayed($event->getChannelUserDataId(), $event->getNoAccessLinks(), $event->getAccessLinks());
  29.         } catch (ClientExceptionInterface|RedirectionExceptionInterface|ServerExceptionInterface|TransportExceptionInterface $e) {
  30.             $this->logger->error($e);
  31.         }
  32.     }
  33. }