Ver Fonte

Mise à jour ActivityListener + mauvais use

François há 5 anos atrás
pai
commit
3e2657ce9e
2 ficheiros alterados com 8 adições e 5 exclusões
  1. 4 0
      config/services.yaml
  2. 4 5
      src/Service/ActivityListener.php

+ 4 - 0
config/services.yaml

@@ -46,6 +46,10 @@ services:
         tags:
             - { name: doctrine.event_listener, event: postPersist }
 
+    App\Service\ActivityListener:
+        tags:
+            - { name: kernel.event_listener, event: kernel.controller }
+
     App\Service\NoteListener:
         arguments:
             - "@App\\Service\\NoteMoyenne"

+ 4 - 5
src/Service/ActivityListener.php

@@ -1,10 +1,9 @@
 <?php
 namespace App\Service;
 
-use AppBundle\Entity\User;
+use App\Entity\User;
 use Doctrine\ORM\EntityManagerInterface;
-use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
-use Symfony\Component\HttpKernel\HttpKernel;
+use Symfony\Component\HttpKernel\Event\ControllerEvent;
 use Symfony\Component\Security\Core\Security;
 
 class ActivityListener
@@ -18,11 +17,11 @@ class ActivityListener
         $this->security = $security;
     }
 
-    public function onCoreController(FilterControllerEvent $event)
+    public function onKernelController(ControllerEvent $event)
     {
         // Check that the current request is a "MASTER_REQUEST"
         // Ignore any sub-request
-        if ($event->getRequestType() !== HttpKernel::MASTER_REQUEST) {
+        if (!$event->isMasterRequest()) {
             return;
         }