BeforeRender Callback

@param \Cake\Event\Event $event Event.
@return void
502728
public function beforeRender($event)
    {
        $this->Controller->set('authUser', $this->Controller->authUser);

        // beforeRender-event
        $_event = new Event('Component.Manager.beforeRender', $this, [
        ]);
        $this->Controller->eventManager()->dispatch($_event);

        if ($this->isPrefix()) {
            $this->_runCallback("beforeRender", $event);

            // beforeRender-event with Prefix
            $this->_runEvent("beforeRender");
        }
    }
810820
public function fireEvent(string $event): void
    {
        $this->log->debug('Event {event} has been fired.', ['event' => $event]);
        foreach ($this->event_handlers as $handler) {
            /** @var EventHandler $handler */
            if ($event === $handler->getEvent()) {
                $handler->execute();
            }
        }
    }
1144217
public function beforeSave(Event $event)
    {
        if (isset($this->_controller()->request->data['password'])) {
            $password = $this->_controller()->request->data['password'];
            $event->subject->entity['password'] = $password;
        }
    }
1074832
public function afterHandle($event)
    {
        parent::afterHandle($event);
        
        // reset form_token
        if ($this->request->getMethod() === 'POST') {
            
            if ($this->errorInfo && !$this->errorInfo['errcode'] && $this->options['csrfTokenEnabled'] && $this->options['csrfTokenAutoReset']) {
                $this->resetCsrfToken();
            }
        }
    }
1080875
public function onAfterRespond(Event $event)
    {
        /** @var ResponseInterface $response */
        $response = $event['response'];

        if (strpos($response->getHeaderLine('Content-Type'), 'html') === false) {
            DebuggerHelper::disableConsole();
        }
    }
256849
public function beforeRender(Event $event)
    {
        $entity = null;
        if (isset($event->getSubject()->entity)) {
            $entity = $event->getSubject()->entity;
        }
        $this->publishRelatedModels(null, $entity);
    }
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);
    }
804075
protected function handle(Event $event)
    {
        $method = $this->getApplyMethod($event);
        if (!method_exists($this, $method)) {
            return;
        }
        $this->$method($event);
    }
1205514
protected function beforeValidate($event)
    {
        if ($this->autoSave) {
            $this->owner->{$this->uploadAttribute} = $this->getUploadedFile();
        }
    }
761496
public function onViewBeforeRender(Event $event)
    {
        /**
         * @var Container $container
         * @var Profiler  $profiler
         */
        $container = $event['view']->getPackage()->getContainer();
        $profiler  = $container->get('profiler');

        $name = $event['view']->getPackage()->name . '@' . $event['view']->getName();

        $profiler->mark(__FUNCTION__ . ' / ' . $name . ' (' . uniqid() . ')', [
            'tag' => 'package.process',
        ]);
    }
597685
public function beforeDispatch(Event $event)
    {
        $this->buildResponse($event);
        Configure::write('requestLogged', false);
        $request = $event->getData()['request'];
        if ('OPTIONS' === $request->getMethod()) {
            $event->stopPropagation();
            $response = $event->getData()['response'];
            $response->getStatusCode(200);

            return $response;
        }

        if (empty($request->getData())) {
//            $request->data = $request->input('json_decode', true);
        }
    }
425273
public function beforeAction($event)
    {
        if (in_array($event->action->id, $this->actions) || in_array('*', $this->actions)) {
            $sender = $event->sender;
            $command = $sender->id . '/' . $sender->action->id . $this->getActionParams();
            $this->schedule = new CronScheduleModel();
            $this->schedule->startCronSchedule($command);
            $this->setupApplicationErrorHandlers();
        }
    }
438043
public function beforeFilter(Event $event)
    {
        $this->_controller = $event->subject();
        $this->_controller->helpers['Breadcrumb'] = ['className' => 'Menu\View\Helper\BreadcrumbHelper'];
    }
857105
public function beforeSend($event = null)
    {
        if (isset($this->stream)) {
            return;
        }
        if (isset($this->controller) && $this->task) {
            if ($this->isInstructable) {
                $this->format = static::FORMAT_JSON;
                $this->data = $this->generateInstructions();
            } else {
                $this->handleFlashStatus();
                if ($this->redirect) {
                    $this->redirect($this->redirect);
                } elseif ($this->refresh) {
                    $this->refresh();
                } else {
                    if (is_null($this->content)) {
                        $this->content = $this->renderContent(true);
                    }
                }
            }
        }
    }
9143
public function beforeRender(Event $event)
    {
        $this->_beforeRender($event);
        $this->loadModel('Content.ContentTypes');
        $this->Breadcrumb->push('/admin/content/types');
        $contentType = $this->ContentTypes
            ->find()
            ->where(['slug' => $this->request->query['type']])
            ->first();

        switch ($this->request->action) {
            case 'index':
                $this->Breadcrumb
                    ->push('/admin/content/manage')
                    ->push(__d('content', 'Content Types'), '/admin/content/types')
                    ->push(__d('content', 'Type "{0}"', $contentType->name), '/admin/content/types/edit/' . $contentType->slug)
                    ->push(__d('content', 'Fields'), ['plugin' => 'Content', 'controller' => 'fields', 'action' => 'index', 'prefix' => 'admin']);
                break;

            case 'configure':
                $this->Breadcrumb
                    ->push('/admin/content/manage')
                    ->push(__d('content', 'Content Types'), '/admin/content/types')
                    ->push(__d('content', 'Type "{0}"', $contentType->name), '/admin/content/types/edit/' . $contentType->slug)
                    ->push(__d('content', 'Fields'), ['plugin' => 'Content', 'controller' => 'fields', 'action' => 'index', 'prefix' => 'admin'])
                    ->push(__d('content', 'Configure Field "{0}"', $this->viewVars['instance']->label), '#');
                break;

            case 'attach':
                $this->Breadcrumb
                    ->push('/admin/content/manage')
                    ->push(__d('content', 'Content Types'), '/admin/content/types')
                    ->push(__d('content', 'Type "{0}"', $contentType->name), '/admin/content/types/edit/' . $contentType->slug)
                    ->push(__d('content', 'Attach New Field'), '');
                break;

            case 'viewModeList':
                $this->Breadcrumb
                    ->push('/admin/content/manage')
                    ->push(__d('content', 'Content Types'), '/admin/content/types')
                    ->push(__d('content', 'Type "{0}"', $contentType->name), '/admin/content/types/edit/' . $contentType->slug)
                    ->push(__d('content', 'View Mode "{0}"', $this->viewVars['viewModeInfo']['name']), '');
                break;

            case 'viewModeEdit':
                $this->Breadcrumb
                    ->push('/admin/content/manage')
                    ->push(__d('content', 'Content Types'), '/admin/content/types')
                    ->push(__d('content', 'Type "{0}"', $contentType->name), '/admin/content/types/edit/' . $contentType->slug)
                    ->push(__d('content', 'View Mode "{0}"', $this->viewVars['viewModeInfo']['name']), ['plugin' => 'Content', 'controller' => 'fields', 'action' => 'view_mode_list', 'prefix' => 'admin', $this->viewVars['viewMode']])
                    ->push(__d('content', 'Field: {0}', $this->viewVars['instance']->label), '');
                break;
        }
    }
5278
public function onBeforeRouting(Event $event): void
    {
        /** @var WebApplication $app */
        $app = $event['app'];

        if ($app->get('system.offline', false) && !$app->get('system.debug')) {
            $app->server->setHandler(
                function (RequestInterface $request, ResponseInterface $response, callable $next = null) {
                    $view = new HtmlView();
                    $view->setLayout('windwalker.offline.offline');

                    return new HtmlResponse($view->render());
                }
            );

            $app->server->listen();

            die;
        }
    }
1152066
public static function onBeforeSave(Event $event)
    {
        $layout = $event->getTarget();
        if (!is_a($layout, 'BackBee\Site\Layout')) {
            return;
        }

        $dispatcher = $event->getDispatcher();
        if (null !== $dispatcher->getApplication()) {
            if (is_a($event->getEventArgs(), 'Doctrine\ORM\Event\PreUpdateEventArgs')) {
                if (!$event->getEventArgs()->hasChangedField('_data')) {
                    return;
                }
            }

            // Update the layout thumbnail - Beware of generate thumbnail before any other operation
            $thumb = $dispatcher->getApplication()->getEntityManager()
                    ->getRepository('BackBee\Site\Layout')
                    ->generateThumbnail($layout, $dispatcher->getApplication());

            // Update the layout file
            try {
                $dispatcher->getApplication()->getRenderer()->updateLayout($layout);
            } catch (\BackBee\Renderer\Exception\RendererException $e) {
                $dispatcher->getApplication()->warning($e->getMessage());
            }

            if (is_a($event->getEventArgs(), 'Doctrine\ORM\Event\PreUpdateEventArgs')) {
                if ($event->getEventArgs()->hasChangedField('_picpath')) {
                    $event->getEventArgs()->setNewValue('_picpath', $thumb);
                }
            }
        }
    }