本文整理匯總了PHP中Phalcon\Mvc\Dispatcher::wasForwarded方法的典型用法代碼示例。如果您正苦於以下問題:PHP Dispatcher::wasForwarded方法的具體用法?PHP Dispatcher::wasForwarded怎麽用?PHP Dispatcher::wasForwarded使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Phalcon\Mvc\Dispatcher
的用法示例。
在下文中一共展示了Dispatcher::wasForwarded方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: beforeDispatch
public function beforeDispatch(Event $event, Dispatcher $dispatcher)
{
$di = $this->getDI();
$request = $di->get('request');
if (!$dispatcher->wasForwarded()) {
if ($request->has($this->method_key)) {
$method = $request->get($this->method_key);
} else {
$method = $request->getHeader('X-HTTP-Method-Override');
}
if (!empty($method)) {
$dispatcher->forward(['action' => $method]);
}
}
if ($request->has($this->format_key)) {
$mime = 'application/' . $request->get($this->format_key);
} else {
$parts = explode(';', $request->getHeader('Accept'));
$mime = reset($parts);
}
if (empty($mime) || $mime == '*/*') {
$mime = 'application/json';
}
$rest = $di->get('rest');
$rest->setFormat($mime);
}
示例2: afterExecuteRoute
public function afterExecuteRoute(\Phalcon\Events\Event $event, \Phalcon\Mvc\Dispatcher $dispatcher)
{
/** @var \Phalcon\Mvc\Router $route */
$route = $dispatcher->getDI()->get('router');
$view = $dispatcher->getDI()->getService('view')->resolve();
$wasForwarded = $dispatcher->wasForwarded();
if ($wasForwarded) {
return;
}
if ($route->getMatchedRoute()) {
$paths = $route->getMatchedRoute()->getPaths();
$controller = $paths['controller'];
$action = \Phalcon\Text::uncamelize($paths['action']);
$action = str_replace("_", "-", $action);
$template = $controller . '/' . $action;
$view->pick([$template]);
}
}