本文整理汇总了PHP中Phalcon\Mvc\Dispatcher::setReturnedValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Dispatcher::setReturnedValue方法的具体用法?PHP Dispatcher::setReturnedValue怎么用?PHP Dispatcher::setReturnedValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Mvc\Dispatcher
的用法示例。
在下文中一共展示了Dispatcher::setReturnedValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeDispatchLoop
public function beforeDispatchLoop(Event $event, Dispatcher $dispatcher)
{
if (!$this->auth->logged_in() && $this->router->getActionName() != 'login' && $this->router->getControllerName() != 'rotator') {
$dispatcher->setReturnedValue($this->response->redirect('login'));
return false;
}
if ($this->router->getControllerName() != 'rotator') {
if ($this->auth->logged_in('admin')) {
$dispatcher->setDefaultNamespace('App\\Controllers\\Admin');
} elseif ($this->auth->logged_in('advertiser')) {
$dispatcher->setDefaultNamespace('App\\Controllers\\Advertiser');
}
}
return true;
}
示例2: beforeException
public function beforeException(Event $event, Dispatcher $dispatcher, Exception $exception)
{
$di = $this->getDI();
$response = $di->get('response');
switch ($exception->getCode()) {
case Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
case Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
$dispatcher->forward(['controller' => 'error', 'action' => 'show404']);
return false;
}
if ($exception instanceof AbstractResponse) {
$response->setContent($exception->getMessage())->setStatusCode($exception->getStatusCode(), $exception->getStatusMessage());
$dispatcher->setReturnedValue($response);
return false;
}
//return $response->setContent($exception->getMessage() . ', ' . $exception->getFile() . ':' . $exception->getLine());
}