public function onKernelResponse(FilterResponseEvent $event)
 {
     $request = $event->getRequest();
     $response = $event->getResponse();
     $responseCode = $response->getStatusCode();
     $annotations = $this->getLoggableAnnotations($request);
     if (is_array($annotations)) {
         foreach ($annotations as $annotation) {
             $actionLogId = $annotation->getActionLogId();
             $this->logger->updateResponseCode($actionLogId, $responseCode);
         }
     }
 }
Exemplo n.º 2
0
 public function onSwitchUser(SwitchUserEvent $event)
 {
     $tokenStorage = $this->tokenStorage;
     $authChecker = $this->authChecker;
     $target = $event->getTargetUser();
     if ($authChecker->isGranted('ROLE_PREVIOUS_ADMIN')) {
         // Impersonator is going back to normal
         foreach ($tokenStorage->getToken()->getRoles() as $role) {
             if ($role instanceof SwitchUserRole) {
                 $impersonator = $role->getSource()->getUser();
                 break;
             }
         }
         $isImpersonating = false;
     } else {
         // Impersonator is becoming the target user
         $impersonator = $this->tokenStorage->getToken()->getUser();
         $isImpersonating = true;
     }
     $controllerAction = array($this, 'onSwitchUser');
     $this->logger->registerImpersonate($event->getRequest(), $target, $impersonator, $controllerAction, $isImpersonating);
 }