本文整理汇总了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]);
}
}