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


PHP Router::parse方法代码示例

本文整理汇总了PHP中core\Router::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::parse方法的具体用法?PHP Router::parse怎么用?PHP Router::parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core\Router的用法示例。


在下文中一共展示了Router::parse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct()
 {
     $app = App::getInstance();
     // On initialise l'objet Request
     if ($_ENV['USE_ROUTES']) {
         require '../Config/routes.php';
         $this->request = Router::run(new Request($app));
     } else {
         $this->request = new Request($app);
     }
     // On parse l'url (définition du controller, action,...)
     Router::parse($this->request);
     // On affiche les erreurs ?
     Debug::set();
     // On charge le bon controller
     try {
         $controller = $this->loadController();
     } catch (SwithException $e) {
         (new SwithError(['message' => "Le controller {$this->request->controller} est introuvable", "title" => "Controlleur introuvable"]))->display();
     }
     if (method_exists($controller, "beforeRender")) {
         $controller->beforeRender();
     }
     // On appelle la fonction
     $action = $this->request->getAction();
     $availablesActions = array_diff(get_class_methods($controller), get_class_methods(get_parent_class($controller)));
     if (in_array($action, $availablesActions)) {
         call_user_func_array([$controller, $action], $this->request->params);
     } else {
         (new SwithError(['message' => "Le controller {$this->request->controller} n'a pas de methode {$action}", "title" => "Methode introuvable"]))->display();
     }
     $controller->render($controller->view);
 }
开发者ID:kranack,项目名称:swithMVC,代码行数:33,代码来源:Dispatcher.php

示例2: Debug

 function __construct()
 {
     LoaderJavascript::add("debug", "controller.init", Conf::$debug);
     LoaderJavascript::add("test", "controller.init");
     $this->debug = new Debug($this);
     $this->debug->handle_errors();
     if (!Conf::$install) {
         $this->roleUser();
     }
     $this->request = new Request();
     Router::parse($this->request->url, $this->request);
 }
开发者ID:CamTosh,项目名称:Mediastorrent,代码行数:12,代码来源:Dispatcher.php

示例3: Request

 function __construct()
 {
     $this->request = new Request();
     Router::parse($this->request->url, $this->request);
     $controller = $this->loadController();
     $action = $this->request->action;
     foreach ($this->request->params as $param) {
         $this->parametre .= $param . ", ";
     }
     $this->parametre = rtrim($this->parametre, ", ");
     if (empty($this->parametre)) {
         $controller->{$action}();
     } else {
         $controller->{$action}($this->parametre);
     }
 }
开发者ID:EquipeK,项目名称:Extranet,代码行数:16,代码来源:Dispatcher.php


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