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