@param GuardEvent $event

@throws Exception
761051
public function onGuard(GuardEvent $event)
    {
        $subject = $event->getSubject();
        $transitionName = $event->getTransition()->getName();

        if ($subject instanceof AbstractSubject) {
            if ($subject->needData() && method_exists($subject, $transitionName)) {
                $reflectionMethod = new ReflectionMethod(get_class($subject), $transitionName);
                $dataProvider = $this->reader->getMethodAnnotation($reflectionMethod, DataProvider::class);
                if ($dataProvider && $dataProvider instanceof DataProvider) {
                    $data = call_user_func([$subject, $dataProvider->method]);
                    if (!is_array($data)) {
                        return;
                    }
                } else {
                    $data = [];
                }
                $subject->setData($data);
            }
        }
    }
805890
public function onKernelException(GetResponseForExceptionEvent $event)
    {
        // Skip HTTP exception
        if ($event->getException() instanceof HttpException) {
            return;
        }

        $this->setException($event->getException());
    }
294304
public function handle(GetResponseEvent $event)
    {
        if (null !== $this->tokenStorage->getToken()) {
            // user is already authenticated, there is nothing to do.
            return;
        }

        // creates an anonymous token with a dedicated role.
        $this->tokenStorage->setToken(
            new AnonymousToken($this->secret, 'anon.', ['ROLE_ANONYMOUS'])
        );

        if (null !== $this->logger) {
            $this->logger->info(sprintf('Populated SecurityContext with an anonymous Token'));
        }
    }
1022682
public function handle(GetResponseEvent $event)
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        if (!$this->authorizationChecker->isGranted(self::ATTRIBUTE, $event->getRequest())) {
            throw new AccessDeniedException();
        }
    }
306679
public function onKernelRequest(GetResponseEvent $event): void
    {
        if (! $event->isMasterRequest()) {
            return;
        }

        $currentClient = Hub::getCurrent()->getClient();
        if (null === $currentClient || ! $currentClient->getOptions()->shouldSendDefaultPii()) {
            return;
        }

        $token = null;

        if ($this->tokenStorage instanceof TokenStorageInterface) {
            $token = $this->tokenStorage->getToken();
        }

        if (
            null !== $token
            && null !== $this->authorizationChecker
            && $token->isAuthenticated()
            && $this->authorizationChecker->isGranted(AuthenticatedVoter::IS_AUTHENTICATED_REMEMBERED)
        ) {
            $userData = $this->getUserData($token->getUser());
        }

        $userData['ip_address'] = $event->getRequest()->getClientIp();

        Hub::getCurrent()
            ->configureScope(function (Scope $scope) use ($userData): void {
                $scope->setUser($userData);
            });
    }
391260
public function onReflectError($event)
    {
        $filename = $event['file']->getPathname();
        $this->stopwatch->stop($filename);

        self::$logger->error(
            'Parse error in {time} on file "{file"}: {error}',
            array(
                'time'  => Timer::toTimeString($time),
                'file'  => $filename,
                'error' => $event['error']
            )
        );
    }
490047
public function handle(GetResponseEvent $event): void
    {
        if ($this->isEnabled()) {
            $hostRole = $this->getHostRole($event);

            if (null !== $hostRole) {
                $this->sidManager->addSpecialRole($hostRole);
            }
        }
    }
243185
public function onKernelException(GetResponseForExceptionEvent $event): void
    {
        $request = $event->getRequest();

        if ($this->kernelDebug && $this->debugParameter && $request->query->has($this->debugParameter)) {
            return;
        }

        $exception = $event->getException();
        $errorPresentation = $this->errorPresentationFactory->create($exception);

        if (!$errorPresentation) {
            return;
        }

        if (!$errorPresentation->getResource()) {
            // The presentation not have resource. Send response with only status code.
            $event->setResponse(new Response('', $errorPresentation->getStatusCode()));

            return;
        }

        $acceptMediaType = null;

        try {
            $serializer = $this->serializerResolver->resolveByMediaTypes(
                get_class($errorPresentation->getResource()),
                $request->getAcceptableContentTypes(),
                $acceptMediaType
            );
        } catch (ResourceSerializerNotFoundException $e) {
            // Cannot resolve the serializer for accept media types.

            return;
        }

        $context = $this->serializationContextCollector->collect();
        $serializedData = $serializer->serialize($errorPresentation->getResource(), $context);

        $response = new Response($serializedData, $errorPresentation->getStatusCode(), [
            'Content-Type' => $acceptMediaType,
        ]);

        $event->setResponse($response);
    }
578456
public function onKernelException(GetResponseForExceptionEvent $event)
    {
        if (($exception = $event->getException()) instanceof NoInputException) {
            $msg = array("message" => "No input data");

            $response = $exception->getResponse()
                ->setStatusCode(Response::HTTP_BAD_REQUEST)
                ->setContent($this->getSerializedContent($msg));

            $event->setResponse($response);
        }
    }
149157
protected function silentRunActionTrigger($event)
    {
        try {
            $this->action->trigger($event, $this->control, $this->context);
        } catch (Exception $exception) {
            // Pokémon Exception Handling
        }
    }
49109
protected function handle($event): void
    {
        $method = $this->getApplyMethod($event);

        if (!method_exists($this, $method)) {
            return;
        }

        $this->$method($event);
    }
86415
public function onBadPacket(ErrorEvent $event) {
        $this->errorResponse($event->sender, $event->code, $event->errstr);   
    }
815308
public function jobException(Event $event)
    {
        $data = $event->data();
        $this->logger()->alert(sprintf('Exception: "%s"', $data['exception']->getMessage()));
    }
1148787
public function handle(Guard $auth, Dispatcher $event, Translator $translator)
    {
        if ($auth->guest()) {
            throw new SessionHasExpired($translator->get('authentication::session.expired'));
        }

        $user = $auth->user();

        $auth->logout();

        $event->fire(new UserHasLoggedOut($user));
    }
1127830
public function onKernelException(GetResponseForExceptionEvent $event)
    {
        if ($this->onlyMasterRequests && HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
            return;
        }

        $this->exception = $event->getException();
    }
1315735
public function guard($guard = HoneypotGuard::class, $options = [])
    {
        if ($this->shouldValidate) $this->validate();
        $this->shouldCallGuard = false;
        if ($this->shouldFallThrough) return $this;

        if (is_string($guard) && !class_exists($guard)) {
            throw new Exception("{$guard} does not exist.");
        }

        if (!is_subclass_of($guard, Guard::class)) {
            throw new Exception('Guards must extend '.Guard::class.'.');
        }

        if (is_string($guard)) {
            $guard = new $guard($this, $options);
        }

        $this->perform($guard);

        return $this;
    }
661969
public function onKernelException(GetResponseForExceptionEvent $event)
    {
        if (!$this->auto) {
            return;
        }

        $exception = $event->getException();

        $report = Report::fromPHPThrowable(
            $this->client->getConfig(),
            $exception
        );
        $report->setUnhandled(true);
        $report->setSeverityReason([
            'type' => 'unhandledExceptionMiddleware',
            'attributes' => [
                'framework' => 'Symfony',
            ],
        ]);

        $this->client->notify($report);
    }