當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。