当前位置: 首页>>代码示例>>PHP>>正文


PHP Dispatcher::wasForwarded方法代码示例

本文整理汇总了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);
 }
开发者ID:serebro,项目名称:phalcon-rest,代码行数:26,代码来源:DispatcherEventsHandler.php

示例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]);
     }
 }
开发者ID:sb15,项目名称:phalcon-ext,代码行数:18,代码来源:ViewTemplateName.php


注:本文中的Phalcon\Mvc\Dispatcher::wasForwarded方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。