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


PHP Q_Request::tail方法代码示例

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


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

示例1: execute

 /**
  * The standard action front controller
  * @method execute
  * @static
  * @throws {Q_Exception_BadUrl}
  * @throws {Q_Exception}
  * @throws {Q_Exception_MissingConfig}
  */
 static function execute($url = null)
 {
     // Fixes for different platforms:
     if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
         // ISAPI 3.0
         $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
     }
     // Set the controller that is being used
     if (!isset(Q::$controller)) {
         Q::$controller = 'Q_ActionController';
     }
     try {
         $slots = Q_Request::slotNames(false);
         $slots = $slots ? ' slots: (' . implode(',', $slots) . ') from' : '';
         $method = Q_Request::method();
         Q::log("{$method}{$slots} url: " . Q_Request::url(true));
         $tail = Q_Request::tail($url);
         if (!isset($tail)) {
             // Bad url was requested somehow
             $url = Q_Request::url(true);
             $base_url = Q_Request::baseUrl(true);
             throw new Q_Exception_BadUrl(compact('base_url', 'url'));
         }
         $parts = explode('/', $tail);
         $parts_len = count($parts);
         if ($parts_len >= 1) {
             $module = $parts[0];
         }
         if ($parts_len >= 2) {
             $action = $parts[1];
         }
         if (empty($module) or empty($action)) {
             throw new Q_Exception("Not implemented");
         }
         // Make sure the 'Q'/'web' config fields are set,
         // otherwise URLs will be formed pointing to the wrong
         // controller script.
         $ar = Q_Config::get('Q', 'web', 'appRootUrl', null);
         if (!isset($ar)) {
             throw new Q_Exception_MissingConfig(array('fieldpath' => 'Q/web/appRootUrl'));
         }
         // Dispatch the request
         $uri = Q_Uri::from(compact('module', 'action'));
         Q_Dispatcher::dispatch($uri);
         $dispatchResult = Q_Dispatcher::result();
         if (!isset($dispatchResult)) {
             $dispatchResult = 'Ran dispatcher';
         }
         if ($module and $action) {
             $slotNames = Q_Request::slotNames();
             $requestedSlots = empty($slotNames) ? '' : implode(',', $slotNames);
             Q::log("~" . ceil(Q::milliseconds()) . 'ms+' . ceil(memory_get_peak_usage() / 1000) . 'kb.' . " {$dispatchResult} for {$module}/{$action}" . " ({$requestedSlots})");
         } else {
             Q::log("~" . ceil(Q::milliseconds()) . 'ms+' . ceil(memory_get_peak_usage() / 1000) . 'kb.' . " No route for " . $_SERVER['REQUEST_URI']);
         }
     } catch (Exception $exception) {
         /**
          * @event Q/exception
          * @param {Exception} exception
          */
         Q::event('Q/exception', compact('exception'));
     }
 }
开发者ID:dmitriz,项目名称:Platform,代码行数:71,代码来源:ActionController.php

示例2: filenamefromUrl

 /**
  * Returns what the local filename of a local URL would typically be without any routing.
  * If not found under docroot, also checks various aliases.
  * @method filenamefromUrl
  * @static
  * @param {string} $url The url to translate, whether local or an absolute url beginning with the base URL
  * @return {string} The complete filename of the file or directory.
  *  It may not point to an actual file or directory, so use file_exists() or realpath()
  */
 static function filenamefromUrl($url)
 {
     if (Q_Valid::url($url)) {
         // This is an absolute URL. Get only the part after the base URL
         // Run it through proxies first
         $url = self::proxyDestination($url);
         $local_url = Q_Request::tail($url);
         if (!isset($local_url)) {
             return null;
         }
     } else {
         $local_url = $url;
     }
     $parts = explode('?', $local_url);
     $local_url = $parts[0];
     if ($local_url == '' || $local_url[0] != '/') {
         $local_url = '/' . $local_url;
     }
     // Try various aliases first
     $aliases = Q_Config::get('Q', 'aliases', array());
     foreach ($aliases as $alias => $path) {
         $alias_len = strlen($alias);
         if (substr($local_url, 0, $alias_len) == $alias) {
             return $path . substr($local_url, $alias_len);
         }
     }
     // Otherwise, we should use the document root.
     $docroot_dir = self::documentRoot();
     return $docroot_dir . $local_url;
 }
开发者ID:atirjavid,项目名称:Platform,代码行数:39,代码来源:Uri.php


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