onBeforeRouting

@param Event $event

@return  void
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;
        }
    }
479954
public function beforePrepare(Event $event)
	{
		$command = $event['command'];
		$operation = $command->getOperation();

		if ($command->getName() !== 'updateEntity' && $command->offsetExists('_id') === true) return;

		$operation->addParam(new Parameter(array(
			'name' => 'body_id',
			'location' => 'json',
			'type' => 'string',
			'default' => $command->offsetGet('_id'),
			'static' => true,
			'sentAs' => '_id'
		)));
	}
727557
public function beforeInsert($event)
    {
        foreach ($this->insert as $field) {
            $event->sender->$field = time();
        }
    }
570929
public function beforeDispatch(Event $event)
    {
        $request = $event->getData('request');
        $response = $event->getData('response');
        $event->setData('controller', $this->_getController($request, $response));
    }
10223
public function beforeRender(Event $event): void
    {
        $this->setJson('isAjax', $this->_controller->request->is('ajax'));
        $this->setJson('isMobile', $this->_controller->request->is('mobile'));
        $this->setBoth('isDialog', $this->_controller->request->is('dialog'));
        $this->setBoth('isJson', $this->_controller->request->is('json'));
        $this->setJson('debug', Configure::read('debug'));

        $ssl = false;
        if (env('HTTPS') || $this->_controller->request->is('ssl') || $this->_controller->request->env('HTTP_X_FORWARDED_PROTO') == 'https') {
            $ssl = true;
        }

        $appData = array(
            'jsonData' => $this->_jsonData,
            'webroot' => 'http' . ($ssl ? 's' : '') . '://' . env('HTTP_HOST') . $this->_controller->request->webroot,
            'url' => $this->_controller->request->url,
            // 'controller' => $this->_controller->name,
            // 'action' => $this->_controller->request->action,
            // 'plugin' => $this->_controller->request->plugin,
            'request' => array(
                'query' => $this->_controller->request->query,
                'pass' => $this->_controller->request->params['pass'],
                'plugin' => $this->_controller->request->plugin,
                'controller' => Inflector::underscore($this->_controller->name),
                'action' => $this->_controller->request->action
            )
        );

        // merge in the additional frontend data
        $appData = Hash::merge($appData, $this->_additionalAppData);
        $this->_controller->set('frontendData', $appData);
        $this->_controller->set('closeDialog', $this->_closeDialog);
    }
1342644
public function beforeSave($event) {
		if ($this->getOwner()->getIsNewRecord() && ($this->createAttribute !== null)) {
			$this->getOwner()->{$this->createAttribute} = $this->getTimestampByAttribute($this->createAttribute);
		}
		if ((!$this->getOwner()->getIsNewRecord() || $this->setUpdateOnCreate) && ($this->updateAttribute !== null)) {
			$this->getOwner()->{$this->updateAttribute} = $this->getTimestampByAttribute($this->updateAttribute);
		}
	}
612700
public static function onPreUpdate(Event $event)
    {
        $page = $event->getTarget();
        $eventArgs = $event->getEventArgs();

        if ($eventArgs instanceof PreUpdateEventArgs) {
            if ($eventArgs->hasChangedField('_workflow_state')) {
                $old = $eventArgs->getOldValue('_workflow_state');
                $new = $eventArgs->getNewValue('_workflow_state');

                if (null !== $new && null !== $listener = $new->getListenerInstance()) {
                    $listener->switchOnState($event);
                }

                if (null !== $old && null !== $listener = $old->getListenerInstance()) {
                    $listener->switchOffState($event);
                }
            }

            if ($eventArgs->hasChangedField('_state')) {
                if (
                    !($eventArgs->getOldValue('_state') & Page::STATE_ONLINE)
                    && $eventArgs->getNewValue('_state') & Page::STATE_ONLINE
                ) {
                    $event->getDispatcher()->triggerEvent('putonline', $page);
                } elseif (
                    $eventArgs->getOldValue('_state') & Page::STATE_ONLINE
                    && !($eventArgs->getNewValue('_state') & Page::STATE_ONLINE)
                ) {
                    $event->getDispatcher()->triggerEvent('putoffline', $page);
                }
            }
        }
    }
1205514
protected function beforeValidate($event)
    {
        if ($this->autoSave) {
            $this->owner->{$this->uploadAttribute} = $this->getUploadedFile();
        }
    }
67948
public function onSuccessActivate(Event $event)
    {
        /** @var User|bool $user */
        $user = $event->getData('user');
        $this->_getMailer($user)->sendActivationMessage();
    }
845532
public function onModelAfterSave(Event $event)
    {
        /** @var User|bool $user */
        $user = $event->getData('user');

        if ($user instanceof EntityInterface) {
            if ($user->isNew() && Filter::bool($user->get('notify'))) {
                $this->_getMailer($user)->sendCreateMessage();
            }
        }
    }
465514
public function beforeFilter(\Cake\Event\Event $event)
    {
        if (isset($this->Csrf) && in_array($event->subject()->request->params['action'], ['upload'])) {
            $this->eventManager()->off($this->Csrf);
        }

        parent::beforeFilter($event);
    }
342659
public function onAfterRespond(Event $event)
    {
        /**
         * @var Container $container
         * @var Collector $collector
         * @var Profiler  $profiler
         */
        $container = $event['app']->getContainer();
        $collector = $container->get('debugger.collector');
        $profiler  = $container->get('profiler');

        $profiler->mark(__FUNCTION__, [
            'tag' => 'system.process',
        ]);
    }
438043
public function beforeFilter(Event $event)
    {
        $this->_controller = $event->subject();
        $this->_controller->helpers['Breadcrumb'] = ['className' => 'Menu\View\Helper\BreadcrumbHelper'];
    }
42724
public function onBefore(BeforeEvent $event)
    {
        $request = $event->getRequest();
        $context = Tracer::spanContext();
        if ($context->enabled()) {
            $request->setHeader($this->propagator->key(), $this->propagator->formatter()->serialize($context));
        }
        $span = Tracer::startSpan([
            'name' => 'GuzzleHttp::request',
            'attributes' => [
                'method' => $request->getMethod(),
                'uri' => $request->getUrl()
            ],
            'kind' => Span::KIND_CLIENT
        ]);
        $this->scope = Tracer::withSpan($span);
    }
718740
public function onInitConfirmation($event)
    {
        $sender = $event->sender;
        /* @var $sender static */
        if (!$sender->confirmationAttribute || empty($sender->confirmationAttribute)) {
            return;
        }
        $sender->confirmation = static::$confirmFalse;
        $sender->confirmCode = '';
    }
1240346
public function beforeFind(Event $event)
    {
        $related = $this->_getRelatedModels();
        if ($related === []) {
            $this->associations = [];
        } else {
            $this->associations = $this->_associations(array_keys($related));
        }

        if (!$event->getSubject()->query->getContain()) {
            $event->getSubject()->query->contain($related);
        }
    }
776725
public function beforePrepare(Event $event)
	{
		$operation = $event['command']->getOperation();
		$client = $event['command']->getClient();

		if ($operation->hasParam('collection') === false) return;
		if (is_null($client->getCollectionName())) return;

		$operation->getParam('collection')->setDefault($client->getCollectionName());
		$operation->getParam('collection')->setStatic(true);

	}