plugins/RewardPointPlugin/Listener/RewardPointNotifyListener.php line 23

Open in your IDE?
  1. <?php
  2. namespace RewardPointPlugin\Listener;
  3. use AppBundle\Listener\AbstractSecurityDisabledListener;
  4. use RewardPointPlugin\Component\Decorator\RewardPointResponseDecorator;
  5. use Symfony\Component\DependencyInjection\ContainerInterface;
  6. use Symfony\Component\HttpKernel\HttpKernelInterface;
  7. use Symfony\Component\HttpKernel\Event\ResponseEvent;
  8. class RewardPointNotifyListener extends AbstractSecurityDisabledListener
  9. {
  10.     /**
  11.      * @var RewardPointResponseDecorator
  12.      */
  13.     private $rewardPointResponseDecorator;
  14.     public function __construct(RewardPointResponseDecorator $rewardPointResponseDecorator)
  15.     {
  16.         $this->rewardPointResponseDecorator $rewardPointResponseDecorator;
  17.     }
  18.     public function onKernelResponse(ResponseEvent $event)
  19.     {
  20.         if ($event->getRequestType() != HttpKernelInterface::MAIN_REQUEST) {
  21.             return;
  22.         }
  23.         $request $event->getRequest();
  24.         $saveNotifyToHeader $request->isXmlHttpRequest() || === strpos($request->getPathInfo(), '/mapi_v2') || === strpos($request->getPathInfo(), '/api_v3');
  25.         $this->rewardPointResponseDecorator->decorate($event->getResponse(), $saveNotifyToHeader);
  26.     }
  27. }