vendor/launchpad/backend/src/Base/EventListener/AppResponseListener.php line 73

Open in your IDE?
  1. <?php
  2. namespace LaunchPad\Bundle\LaunchPadBundle\Base\EventListener;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. use LaunchPad\Bundle\LaunchPadBundle\Api\Controller\BaseApiController;
  5. use LaunchPad\Bundle\LaunchPadBundle\Base\Service\User\UserActionService;
  6. use Symfony\Component\DependencyInjection\ContainerInterface;
  7. use Symfony\Component\HttpKernel\Event\ResponseEvent;
  8. use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
  9. class AppResponseListener
  10. {
  11.     /**
  12.      * @var EntityManagerInterface
  13.      */
  14.     private $em;
  15.     /**
  16.      * @var UserActionService
  17.      */
  18.     private $userActionService;
  19.     /**
  20.      * @var ContainerInterface
  21.      */
  22.     private $container;
  23.     /** @var AuthorizationCheckerInterface  */
  24.     private $authChecker;
  25.     /**
  26.      * AppResponseListener constructor.
  27.      *
  28.      * @param ContainerInterface $container
  29.      * @param AuthorizationCheckerInterface $authChecker
  30.      * @param UserActionService $userActionService
  31.      */
  32.     public function __construct(
  33.         ContainerInterface $container,
  34.         UserActionService $userActionService,
  35.         EntityManagerInterface $em,
  36.         AuthorizationCheckerInterface $authChecker
  37.     )
  38.     {
  39.         $this->container $container;
  40.         $this->userActionService $userActionService;
  41.         $this->em $em;
  42.         $this->authChecker $authChecker;
  43.     }
  44.     /**
  45.      * Check if status success and set successful status in userAction
  46.      *
  47.      * @param ResponseEvent $event
  48.      */
  49.     public function onKernelResponse(ResponseEvent $event)
  50.     {
  51.         $controller $event->getRequest()->attributes->get('_controller');
  52.         $controller explode('\\'$controller);
  53.         $controller end($controller);
  54.         $controller explode('::'$controller);
  55.         $controllerName $controller[0];
  56.         $controllerName substr($controllerName0, -10);
  57.         // Get controller action
  58.         $controllerAction = @$controller[1];
  59.         if (substr($controllerAction, -6) === 'Action') {
  60.             $controllerAction substr($controllerAction0, -6);
  61.         }
  62.         $action lcfirst($controllerName) . '.' $controllerAction;
  63.         $userAction $this->userActionService->getLastUserAction($action);
  64.        // if($action == 'twig.controller.show')
  65.       //  dump($action);die;
  66. //        if ($action !== 'auth.login' || $action != 'twig.controller.show') {
  67. //
  68. //            $userAction = $this->userActionService->getLastUserAction($action);
  69. //
  70. //            if ($event->getResponse()->getStatusCode() === 200) {
  71. //                $userAction->setIsSuccessful(true);
  72. //            } else {
  73. //                $userAction->setIsSuccessful(false);
  74. //            }
  75. //
  76. //            $this->em->flush();
  77. //        }
  78.     }
  79. }