@param ControllerEvent $event

@throws InvalidArgumentException
@throws ReflectionException
178989
public function onKernelController(ControllerEvent $event): void
    {
        if (!$this->check($event)) {
            return;
        }

        if ($annotation = $this->getAnnotation($event)) {
            $annotation->setData($this->getAttributes($event));
            /* @var $annotation Cache */
            $response = $this->getCache($annotation->getKey($event->getRequest()->get(self::ROUTE)));
            if (null !== $response) {
                $event->setController(function () use (
                    $response
                ) {
                    return $response;
                });
            }
        }
    }
813036
public function initializePanels(ActionEvent $event)
    {
        if (!$this->scopeDeterminator->currentScopeIsBackend()) {
            return;
        }

        if (!\in_array(
            $event->getAction()->getName(),
            ['copy', 'create', 'paste', 'delete', 'move', 'undo', 'edit', 'toggle', 'showAll', 'show']
        )
        ) {
            return;
        }

        $environment = $event->getEnvironment();
        $definition  = $environment->getDataDefinition();
        $view        = $environment->getView();

        if (!$view instanceof BaseView
            || !$view->getPanel()
            || !$definition->hasDefinition(Contao2BackendViewDefinitionInterface::NAME)
        ) {
            return;
        }

        /** @var Contao2BackendViewDefinitionInterface $backendDefinition */
        $backendDefinition = $definition->getDefinition(Contao2BackendViewDefinitionInterface::NAME);
        $listingConfig     = $backendDefinition->getListingConfig();

        $dataConfig = $environment->getBaseConfigRegistry()->getBaseConfig();
        $panel      = $view->getPanel();

        ViewHelpers::initializeSorting($panel, $dataConfig, $listingConfig);
    }
588009
public function onCoreController(FilterControllerEvent $event)
    {
        // do not capture admin cms urls
        if (!preg_match('/.*\/admin\/.*/', $event->getRequest()->getRequestUri())) {
            return;
        }

        if (!$this->tokenStorage->getToken()) {
            return;
        }

        $user = $this->tokenStorage->getToken()->getUser();
        if ($user instanceof UserInterface) {

            //here we can update the user as necessary
            if (method_exists($user, 'setLastActivity')) {
                try {
                    $user->setLastActivity(new \DateTime('now'));
                    $this->em->persist($user);
                    $this->em->flush($user);
                } catch (\Doctrine\ORM\ORMException $e) {
                    //do nothing, entity manager is closed
                }
            }
        }
    }
692854
private function executeEvent(AbstractEvent $event)
    {
        $eventName = ClassUtils::getShortName($event);
        $method    = sprintf('apply%s', (string) $eventName);

        if (!method_exists($this, $method)) {
            throw new BadMethodCallException(
                sprintf(
                    'You must define the %s::%s(%s $event) method in order to apply event named "%s".',
                    get_class($this),
                    $method,
                    get_class($event),
                    $eventName
                )
            );
        }

        $this->$method($event);
    }
271232
protected static function instantiateConsoleInteraction(Event $event) {
        $consoleIO                = $event->getIO();
        self::$consoleInteraction = new ConsoleInteraction(new Input($consoleIO), new Output($consoleIO));
    }
152839
public function onKernelView(GetResponseForControllerResultEvent $event): void
    {
        $request = $event->getRequest();
        if ($request->isMethodSafe(false) || !($attributes = RequestAttributesExtractor::extractAttributes($request)) || !$attributes['persist']) {
            return;
        }

        $controllerResult = $event->getControllerResult();
        if (!$this->dataPersister->supports($controllerResult, $attributes)) {
            return;
        }

        switch ($request->getMethod()) {
            case 'PUT':
            case 'PATCH':
            case 'POST':
                $persistResult = $this->dataPersister->persist($controllerResult, $attributes);

                if (null === $persistResult) {
                    @trigger_error(sprintf('Returning void from %s::persist() is deprecated since API Platform 2.3 and will not be supported in API Platform 3, an object should always be returned.', DataPersisterInterface::class), E_USER_DEPRECATED);
                } else {
                    $controllerResult = $persistResult;
                    $event->setControllerResult($controllerResult);
                }

                if (null === $this->iriConverter) {
                    return;
                }

                $hasOutput = true;
                if (null !== $this->resourceMetadataFactory) {
                    $resourceMetadata = $this->resourceMetadataFactory->create($attributes['resource_class']);
                    $outputMetadata = $resourceMetadata->getOperationAttribute($attributes, 'output', ['class' => $attributes['resource_class']], true);
                    $hasOutput = \array_key_exists('class', $outputMetadata) && null !== $outputMetadata['class'] && $controllerResult instanceof $outputMetadata['class'];
                }

                if ($hasOutput) {
                    $request->attributes->set('_api_write_item_iri', $this->iriConverter->getIriFromItem($controllerResult));
                }
            break;
            case 'DELETE':
                $this->dataPersister->remove($controllerResult);
                $event->setControllerResult(null);
                break;
        }
    }
525505
public function onProductShow(ResourceControllerEvent $event): void
    {
        $product = $event->getSubject();
        if (!$product instanceof ProductInterface) {
            return;
        }

        $currentRequest = $this->requestStack->getCurrentRequest();
        if ($currentRequest instanceof Request) {
            $currentRequest->attributes->set('nglayouts_sylius_product', $product);
            // We set context here instead in a ContextProvider, since sylius.product.show
            // event happens too late, after onKernelRequest event has already been executed
            $this->context->set('sylius_product_id', (int) $product->getId());
        }
    }
1262030
public function onKernelController(FilterControllerEvent $event)
    {
        $controllerDefinition = $event->getController();
        $controller = $controllerDefinition[0];

        if (
            !$controller instanceof SecuredControllerInterface &&
            !$controller instanceof SecuredObjectControllerInterface
        ) {
            return;
        }

        $request = $event->getRequest();

        // find appropriate permission type for request
        $permission = '';

        switch ($request->getMethod()) {
            case 'GET':
                $permission = PermissionTypes::VIEW;
                break;
            case 'POST':
                if ('postAction' == $controllerDefinition[1]) { // means that the ClassResourceInterface has to be used
                    $permission = PermissionTypes::ADD;
                } else {
                    $permission = PermissionTypes::EDIT;
                }
                break;
            case 'PUT':
            case 'PATCH':
                $permission = PermissionTypes::EDIT;
                break;
            case 'DELETE':
                $permission = PermissionTypes::DELETE;
                break;
        }

        $securityContext = null;
        $locale = $controller->getLocale($request);
        $objectType = null;
        $objectId = null;

        if ($controller instanceof SecuredObjectControllerInterface) {
            $objectType = $controller->getSecuredClass();
            $objectId = $controller->getSecuredObjectId($request);
        }

        // check permission
        if ($controller instanceof SecuredControllerInterface) {
            $securityContext = $controller->getSecurityContext();
        }

        if (null !== $securityContext) {
            $this->securityChecker->checkPermission(
                new SecurityCondition($securityContext, $locale, $objectType, $objectId),
                $permission
            );
        }
    }
1317706
public function afterFilter(Event $event)
    {
        $pluginEvent = Plugin::getData('Core', 'Controller.afterFilter');
        if (is_callable($pluginEvent->find(0)) && Plugin::hasManifestEvent('Controller.afterFilter')) {
            call_user_func_array($pluginEvent->find(0), [$this, $event]);
        }
    }
96157
public function handleAddEnclosureToTemplate(AddEnclosureToTemplateEvent $event)
    {
        /** @var Controller $controllerAdapter */
        $controllerAdapter = $this->framework->getAdapter(Controller::class);

        $controllerAdapter->addEnclosuresToTemplate(
            $event->getTemplate(),
            $event->getEnclosureData(),
            $event->getKey()
        );
    }
1239293
public function getController(FilterControllerEvent $event): void
    {
        if (!$this->enabled || $event->getRequestType() !== Kernel::MASTER_REQUEST) {
            return;
        }

        $request = $event->getRequest();

        $view = $request->attributes->get('view');
        if (!$view instanceof View || $view->getViewType() !== 'full') {
            return;
        }

        if (is_string($view->getTemplateIdentifier())) {
            return;
        }

        $event->setController(
            function (): RedirectResponse {
                $rootLocationId = $this->configResolver->getParameter('content.tree_root.location_id');

                return new RedirectResponse(
                    $this->urlGenerator->generate('ez_urlalias', ['locationId' => $rootLocationId]),
                    RedirectResponse::HTTP_MOVED_PERMANENTLY
                );
            }
        );
    }
808961
public function handle(DomainEvent $event) : void {
        $method = lcfirst($this->getShortName($event));
        if (method_exists($this, $method)) {
            $this->$method($event);
        }
    }
467700
public function handleAction(ActionEvent $event)
    {
        if (!$this->scopeDeterminator->currentScopeIsBackend()) {
            return;
        }

        $this->checkLanguage($event->getEnvironment(), 'create' === $event->getAction()->getName());
    }
255612
public function onKernelController(FilterControllerEvent $event)
    {
        $request = $event->getRequest();

        // Check if the event has a nodeTranslation, if not this method can be skipped
        if (!$request->attributes->has('_nodeTranslation')) {
            return;
        }

        $nodeTranslation = $request->attributes->get('_nodeTranslation');
        if (!($nodeTranslation instanceof NodeTranslation)) {
            throw new \Exception('Invalid _nodeTranslation value found in request attributes');
        }
        $entity = $nodeTranslation->getRef($this->em);

        // If the entity is an instance of the SlugActionInterface, change the controller
        if ($entity instanceof SlugActionInterface) {
            $request->attributes->set('_entity', $entity);

            // Do security check by firing an event that gets handled by the SlugSecurityListener
            $securityEvent = new SlugSecurityEvent();
            $securityEvent
                ->setNode($nodeTranslation->getNode())
                ->setEntity($entity)
                ->setRequest($request)
                ->setNodeTranslation($nodeTranslation);

            $this->eventDispatcher->dispatch(Events::SLUG_SECURITY, $securityEvent);

            // Set the right controller
            $request->attributes->set('_controller', $entity->getControllerAction());
            $event->setController($this->resolver->getController($request));
        }
    }
761521
protected function dispatchEvent($event)
    {
        if (!$this->container) {
            throw new \RuntimeException("The container has not been set up.");
        }
        $dir = $this->container->getParameter('base_dir');
        if (!is_dir($dir) || !is_readable($dir)) {
            throw new \RuntimeException("'${dir}' is not a valid readable directory.");
        }
        $dispatcher = $this->container->get('event_dispatcher');
        $dispatcher->dispatch($event);
    }
503135
public function onKernelController(FilterControllerEvent $event)
    {
        $request    = $event->getRequest();
        $controller = $event->getController();

        if (is_callable($controller) && method_exists($controller, '__invoke')) {
            $controller = [$controller, '__invoke'];
        }
        
        $this->scopeFetcher->setController($controller);

        $attributeName = $this->getAttributeName($controller);
        $request->attributes->set($attributeName, $this->scopeFetcher);
    }
1277935
public function authorizeActionsOnControllerArguments(FilterControllerArgumentsEvent $event): void
    {
        foreach ($event->getArguments() as $argument) {
            if ($argument instanceof AuthorizeActionInterface) {
                $this->authorizationChecker->verify($argument);
            }
        }
    }