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


PHP Url::detectUri方法代码示例

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


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

示例1: dispatch

 /**
  * Dispatch
  * @return bool
  */
 public function dispatch()
 {
     // Detect the current URI.
     $uri = Url::detectUri();
     // First, we will supose that URI is associated with an Asset File.
     if (Request::isGet() && $this->dispatchFile($uri)) {
         return true;
     }
     // Not an Asset File URI? Routes the current request.
     $method = Request::getMethod();
     // Search the defined Routes for matches; invoke the associated Callback, if any.
     foreach ($this->routes as $route) {
         if ($route->match($uri, $method, false)) {
             // Found a valid Route; process it.
             $this->matchedRoute = $route;
             $callback = $route->callback();
             if (is_object($callback)) {
                 // Invoke the Route's Callback with the associated parameters.
                 call_user_func_array($callback, $route->params());
                 return true;
             }
             // Pattern based Route.
             $regex = $route->regex();
             // Prepare the URI used by autoDispatch, applying the REGEX if exists.
             if (!empty($regex)) {
                 $uri = preg_replace('#^' . $regex . '$#', $callback, $uri);
             } else {
                 $uri = $callback;
             }
             break;
         }
     }
     // Auto-dispatch the processed URI; quit if the attempt finished successfully.
     if ($this->autoDispatch($uri)) {
         return true;
     }
     // The dispatching failed; invoke the Error Callback with the current URI as parameter.
     $params = array(htmlspecialchars($uri, ENT_COMPAT, 'ISO-8859-1', true));
     $this->invokeObject($this->callback(), $params);
     return false;
 }
开发者ID:sisnox,项目名称:framework,代码行数:45,代码来源:ClassicRouter.php

示例2: dispatch

 /**
  * Dispatch route
  * @return bool
  */
 public function dispatch()
 {
     // Detect the current URI.
     $uri = Url::detectUri();
     // First, we will supose that URI is associated with an Asset File.
     if (Request::isGet() && $this->dispatchFile($uri)) {
         return true;
     }
     // Not an Asset File URI? Routes the current request.
     $method = Request::getMethod();
     // If there exists a Catch-All Route, firstly we add it to Routes list.
     if ($this->defaultRoute !== null) {
         array_push($this->routes, $this->defaultRoute);
     }
     foreach ($this->routes as $route) {
         if ($route->match($uri, $method)) {
             // Found a valid Route; process it.
             $this->matchedRoute = $route;
             $callback = $route->callback();
             if ($callback !== null) {
                 // Invoke the Route's Callback with the associated parameters.
                 return $this->invokeObject($callback, $route->params());
             }
             return true;
         }
     }
     // No valid Route found; invoke the Error Callback with the current URI as parameter.
     $params = array(htmlspecialchars($uri, ENT_COMPAT, 'ISO-8859-1', true));
     $this->invokeObject($this->callback(), $params);
     return false;
 }
开发者ID:sisnox,项目名称:framework,代码行数:35,代码来源:Router.php


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