onAfterRender

@param Event $event

@return  void
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',
        ]);
    }
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);
    }
832258
public static function onFlushContent(Event $event)
    {
        $content = $event->getTarget();
        if (!($content instanceof AbstractClassContent)) {
            return;
        }

        $page = $content->getMainNode();
        if (null === $page) {
            return;
        }

        $newEvent = new Event($page, $content);
        $newEvent->setDispatcher($event->getDispatcher());
        self::onFlushPage($newEvent);
    }
1148441
public function afterFind($event)
    {
        foreach ($this->attributes as $attribute) {
            $this->owner->{$attribute} = $this->htmlEncode($this->owner->{$attribute});
        }
    }
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]);
        }
    }
618460
public function afterStore(Event $event) {
		$this->pathBuilder($event->getSubject()->pathBuilder());
		$this->subject = $event->getSubject();

		$this->autoProcessImageVersions($event->getData('entity'), 'create');
	}
883339
public function after($event = []) {
		$modelDynSchema = ClassRegistry::init('CakeLdap.DynSchema');
		$modelDynSchema->updateSchema($event, $this->connection);
	}
780049
public static function onPreUpdate(Event $event)
    {
        $page = $event->getTarget();
        $eventArgs = $event->getEventArgs();
        $updateParents = false;
        $new = $old = null;

        $pageCountModifier = -1;
        if ($eventArgs instanceof PreUpdateEventArgs) {
            if ($page instanceof Page && $eventArgs->hasChangedField('_section')) {
                $old = $eventArgs->getOldValue('_section');
                $new = $eventArgs->getNewValue('_section');

                if ($new->getUid() === $page->getUid()) {
                    return;
                }
                $updateParents = true;
            }

            if ($page instanceof Page && $eventArgs->hasChangedField('_state')) {
                if ($page->getParent() !== null) {
                    if ($eventArgs->getNewValue('_state') >= 4) {
                        $old = $page->getParent()->getSection();
                        if (!$page->isLeaf()) {
                            $pageCountModifier = 0;
                        }
                    } else {
                        $new = $page->getParent()->getSection();
                    }
                    $updateParents = true;
                }
            }

            if ($page instanceof Section && $eventArgs->hasChangedField('_parent')) {
                $old = $eventArgs->getOldValue('_parent');
                $new = $eventArgs->getNewValue('_parent');
                $updateParents = true;
            }

            if ($updateParents) {
                $em = $event->getApplication()->getEntityManager();

                self::setSectionHasChildren($em, $old, $pageCountModifier);
                self::setSectionHasChildren($em, $new, +1);
            }
        }
    }
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();
            }
        }
    }
1127134
public function onAfterRender(Event $event)
    {
        $config = Ioc::getConfig();

        $array = $config->flatten();

        $keys = array_map(function ($value) {
            return StringHelper::quote($value) . ' instanceof mixed';
        }, array_keys($array));

        $data = str_replace('{config}', implode(",\n", $keys), $this->tmpl);

        File::write(WINDWALKER_TEMP . '/ide/.phpstorm.meta.php', $data);

        // For php toolbox
        $tmpl = <<<TMPL
{
    "registrar": [
        {
            "language": "php",
            "provider": "config",
            "signature": [
                "Windwalker\\\\Core\\\\Config\\\\Config:get",
                "Windwalker\\\\Core\\\\Config\\\\Config:set",
                "Windwalker\\\\Application\\\\AbstractApplication:get",
                "Windwalker\\\\Application\\\\AbstractApplication:set",
            ]
        }
    ],
    "providers": [
        {
            "name": "config",
            "lookup_strings": [
                {config}
            ]
        }
    ]
}
TMPL;

        $array = $config->flatten();

        $keys = array_map(function ($value) {
            return StringHelper::quote($value, '"');
        }, array_keys($array));

        $data = str_replace('{config}', implode(",\r\n", $keys), $tmpl);

        File::write(WINDWALKER_TEMP . '/ide/config/.ide-toolbox.metadata.json', $data);
    }
1310723
private function fireEvent($event)
    {
        $env = $this->formatEventName($event);

        if (emitter()->bound($env)) {
            emitter()->emit($env, $this);
        }
    }
854545
public function onAfterInitialise(Event $event)
    {
        /**
         * @var Container $container
         * @var Collector $collector
         * @var Profiler  $profiler
         */
        $container = $event['app']->getContainer();
        $collector = $container->get('debugger.collector');
        $profiler  = $container->get('profiler');
        $input     = $container->get('input');

        // Push exception collector
        $container->get('error.handler')->addHandler(function ($exception) use ($container) {
            if (!$container->exists('debugger.collector')) {
                return;
            }

            $collector = $container->get('debugger.collector');

            /** @var \Exception $exception */
            $collector['exception'] = [
                'type' => get_class($exception),
                'message' => $exception->getMessage(),
                'code' => $exception->getCode(),
                'file' => $exception->getFile(),
                'line' => $exception->getLine(),
                'trace' => BacktraceHelper::normalizeBacktraces($exception->getTrace()),
            ];
        });

        $collector['system.name'] = $event['app']->getName();
        $collector['system.time'] = Chronos::create('now', Chronos::TZ_LOCALE)->format(Chronos::FORMAT_YMD_HIS);
        $collector['system.uri']  = get_object_vars($container->get('uri'));
        $collector['system.ip']   = $input->server->getString('REMOTE_ADDR');

        $collector['system.method.http']   = $input->getMethod();
        $collector['system.method.custom'] = strtoupper($input->get('_method'));

        $profiler->mark(__FUNCTION__, [
            'tag' => 'system.process',
        ]);
    }
1097666
public function beforeRender(Event $event) {
		/** @var \Cake\Controller\Controller $controller */
		$controller = $event->getSubject();

		if (!$controller->getRequest()->is('ajax')) {
			return null;
		}

		$headerKey = $this->getConfig('headerKey');
		if (!$headerKey) {
			return null;
		}

		$ajaxMessages = array_merge_recursive(
			(array)$controller->getRequest()->getSession()->consume('Flash'),
			(array)Configure::consume('TransientFlash')
		);

		$array = [];
		foreach ($ajaxMessages as $key => $stack) {
			foreach ($stack as $message) {
				$array[$key][] = [
					'message' => $message['message'],
					'type' => $message['type'],
					'params' => $message['params']
				];
			}
		}

		// The header can be read with JavaScript and the flash messages can be displayed
		$this->getController()->setResponse($controller->getResponse()->withHeader($headerKey, json_encode($array)));
	}
972468
public function onBeforeSend(Event $event)
    {
        /** @var \Guzzle\Http\Message\Request $request */
        $request = $event['request'];

        list($newUrl, $port) = $this->proxify(
            $request->getUrl(),
            $this->bucketKey,
            $this->gatewayHost
        );

        $request->setUrl($newUrl);

        if ($port) {
            $request->setHeader('Runscope-Request-Port', $port);
        }

        if ($this->authToken) {
            $request->setHeader('Runscope-Bucket-Auth', $this->authToken);
        }
    }
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',
        ]);
    }
804075
protected function handle(Event $event)
    {
        $method = $this->getApplyMethod($event);
        if (!method_exists($this, $method)) {
            return;
        }
        $this->$method($event);
    }
1343445
public function onBeforeSend(Event $event)
    {
        /** @var $request Request */
        $request = $event['request'];

        $id = $this->signatureCredentials->getMacId();
        $ts = $this->timeProvider->getCurrentTime()->getTimestamp();
        $nonce = $this->randomProvider->generateStringForRanges($this->nonceLength, self::$characterRanges);
        $ext = $this->extensionProvider->getExtensionParameters($request, $this->signatureCredentials, $ts, $nonce);
        $ext = http_build_query($ext, null, '&');
        $mac = $this->algorithmManager->generateMac($request, $this->signatureCredentials, $ts, $nonce, $ext);

        $params = array(
            'id' => $id,
            'ts' => $ts,
            'nonce' => $nonce,
            'ext' => $ext,
            'mac' => $mac,
        );

        $list = array();
        foreach ($params as $key => $value) {
            $list[] = $key . '="' . $value . '"';
        }
        $header = 'MAC ' . implode(', ', $list);

        $request->setHeader('Authorization', $header);
    }