On view event

@param ActionViewEvent $event
177876
public function onView(ActionViewEvent $event)
    {
        $message = sprintf(
            'The action "%s" return not ResponseInterface instance. Try create Response instance via result data...',
            $event->getAction()->getName()
        );

        $this->logger->debug($message);
    }
804075
protected function handle(Event $event)
    {
        $method = $this->getApplyMethod($event);
        if (!method_exists($this, $method)) {
            return;
        }
        $this->$method($event);
    }
1216278
public function onIndex(IndexEvent $event)
    {
        try {
            $this->searchManager->index($event->getSubject());
        } catch (MetadataNotFoundException $ex) {
            // no metadata found => do nothing
        }
    }
381785
public function beforeFilter(Event $event)
    {
        $this->viewBuilder()->className(Configure::read('CA.viewClass'))->theme(Configure::read('CA.theme'));

        if ($this->authUser) {
            $this->viewBuilder()->layout(Configure::read('CA.layout.default'));
        } else {
            $this->viewBuilder()->layout(Configure::read('CA.layout.login'));
        }

        $this->_addNotificationMenu();

        $event = new Event('CakeAdmin.Controller.beforeFilter', $this);
        EventManager::instance()->dispatch($event);
    }
769016
public function onPostRender(FilterPostRenderEvent $event): void
    {
        foreach ($this->registry->getTemplateFilters() as $filter) {
            if (null !== ($mailRendered = $event->getMailRendered())
                    && $filter->supports($mailRendered)) {
                $filter->filter($mailRendered);
            }
        }
    }
886816
public function dispatchUntil(ActionEvent $event, callable $callback): void
    {
        foreach ($this->getListeners($event) as $listenerHandler) {
            $listener = $listenerHandler->getActionEventListener();
            $listener($event);

            if ($event->propagationIsStopped()) {
                return;
            }
            if ($callback($event) === true) {
                return;
            }
        }
    }
782855
public function listen(ApplicationEvent $event) {
    if ($event->getStage() == ApplicationEvent::BEFORE_ROUTE_ACTION) {
      $request = $event->getRequest();
      if ($request != null) {
        $this->transformRequest($request);
      }
    }
    else if ($event->getStage() == ApplicationEvent::AFTER_EXECUTE_CONTROLLER) {
      $request = $event->getRequest();
      $response = $event->getResponse();
      if ($request != null && $response != null) {
        $this->transformResponse($request, $response);
      }
    }
  }
1105328
public function onFormSuccess(FormEvent $event)
    {
        $form = $event->getForm();

        $result = $this->createResult($form);

        if ($form->getStoreResults()) {
            $this->storeResult($form, $result);
        }

        if ($form->getSendMail()) {
            $this->sendMail($form, $result);
        }

        $successUrl = $form->getSuccessUrl();

        if ($successUrl != null) {
            $redirectResponse = new RedirectResponse($successUrl);
            $redirectResponse->send();
        }
    }
845048
public function beforeRender(Event $event)
    {
        if (!Configure::read('debug')) {
            return;
        }

        $this->_action()->setConfig('serialize.queryLog', 'queryLog');
        $this->_controller()->set('queryLog', $this->_getQueryLogs());
    }
1143911
public function onKernelView(GetResponseForControllerResultEvent $event): void
    {
        $request = $event->getRequest();
        if (!RequestAttributesExtractor::extractAttributes($request)) {
            return;
        }

        $user = $event->getControllerResult();
        if (!$user instanceof UserInterface || $request->isMethodSafe(false)) {
            return;
        }

        if ('DELETE' === $request->getMethod()) {
            $this->userManager->deleteUser($user);
            $event->setControllerResult(null);
        } else {
            $this->userManager->updateUser($user);
        }
    }
1069414
public function onRenderPage(PageRenderEvent $event)
    {
        $currentView = $event->getCurrentView();

        if ($currentView instanceof VirtualBusinessPage) {
            $currentView->setCssHash($currentView->getTemplate()->getCssHash());
        } elseif (!$currentView->getCssHash() || !$currentView->isCssUpToDate()) {

            //CSS file will be regenerated during WidgetSubscriber onFlush event
            $currentView->changeCssHash();
            $this->entityManager->persist($currentView);
            $this->entityManager->flush($currentView);
        }
    }
1170657
public function selectRenderer(ViewEvent $event)
    {
        $model = $event->getModel();
        
        if ($model instanceof Model\PdfModel) {
            return $this->renderer;
        }

        return null;
    }
300482
public function setupLayout(MvcEvent $event)
    {
        $viewModel = $event->getResult();
        if (!$this->viewRenderer instanceof PhpRenderer
            || !$viewModel instanceof ViewModel
            || $viewModel->terminate()) {
            return;
        }
        $this->configureView();
    }
713807
private function checkPermission(ActionEvent $event)
    {
        $environment = $event->getEnvironment();

        if (true === $environment->getDataDefinition()->getBasicDefinition()->isEditable()) {
            return true;
        }

        $inputProvider = $environment->getInputProvider();

        $event->setResponse(
            \sprintf(
                '<div style="text-align:center; font-weight:bold; padding:40px;">
                    You have no permission for edit model %s.
                </div>',
                ModelId::fromSerialized($inputProvider->getParameter('id'))->getSerialized()
            )
        );

        return false;
    }
867837
public function injectResponse(ViewEvent $event)
    {
        $renderer = $event->getRenderer();
        if ($renderer !== $this->renderer) {
            // Discovered renderer is not ours; do nothing
            return;
        }

        $result = $event->getResult();
        if (!is_string($result)) {
            // No output to display. Good bye!
            return;
        }
        
        $response = $event->getResponse();
        $response->setContent($result);

        $model   = $event->getModel();
        $options = $model->getOptions();

        $fileName        = $options['fileName'];
        $dispositionType = $options['display'];

        if (substr($fileName, -4) != '.pdf') {
            $fileName .= '.pdf';
        }

        $headerValue = sprintf('%s; filename="%s"', $dispositionType, $fileName);

        $response->getHeaders()->addHeaderLine('Content-Disposition', $headerValue);
        $response->getHeaders()->addHeaderLine('Content-Length', strlen($result));
        $response->getHeaders()->addHeaderLine('Content-Type', 'application/pdf');
    }
12473
public function handleEvent(ActionEvent $event)
    {
        $response = $this->process($event->getAction(), $event->getEnvironment());
        $event->setResponse($response);
    }
299271
private function checkPermission(ActionEvent $event)
    {
        $environment = $event->getEnvironment();

        if (true === $environment->getDataDefinition()->getBasicDefinition()->isEditable()) {
            return true;
        }

        $event->setResponse(
            \sprintf(
                '<div style="text-align:center; font-weight:bold; padding:40px;">
                    You have no permission for toggle %s.
                </div>',
                $this->getOperation($event->getAction(), $environment)->getToggleProperty()
            )
        );

        return false;
    }