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


PHP Yii::resetCustomPath方法代码示例

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


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

示例1: createController

 /**
  * Creates a controller instance based on a route.
  * Modified to check in /custom for controller files.
  * See {@link CWebApplication::createController()} for details.
  *
  * @param string $route the route of the request.
  * @param CWebModule $owner the module that the new controller will belong to. Defaults to null, meaning the application
  * instance is the owner.
  * @return array the controller instance and the action ID. Null if the controller class does not exist or the route is invalid.
  */
 public function createController($route, $owner = null)
 {
     if ($owner === null) {
         $owner = $this;
     }
     if (($route = trim($route, '/')) === '') {
         $route = $owner->defaultController;
     }
     $caseSensitive = $this->getUrlManager()->caseSensitive;
     $route .= '/';
     while (($pos = strpos($route, '/')) !== false) {
         $id = substr($route, 0, $pos);
         if (!preg_match('/^\\w+$/', $id)) {
             return null;
         }
         if (!$caseSensitive) {
             $id = strtolower($id);
         }
         $route = (string) substr($route, $pos + 1);
         if (!isset($basePath)) {
             if (isset($owner->controllerMap[$id])) {
                 return array(Yii::createComponent($owner->controllerMap[$id], $id, $owner === $this ? null : $owner), $this->parseActionParams($route));
             }
             if (($module = $owner->getModule($id)) !== null) {
                 // fix module's base paths in case module was loaded from /custom
                 $module->basePath = Yii::resetCustomPath($module->basePath);
                 $module->viewPath = Yii::resetCustomPath($module->viewPath);
                 Yii::setPathOfAlias($module->getId(), $module->basePath);
                 return $this->createController($route, $module);
             }
             $basePath = $owner->getControllerPath();
             $controllerID = '';
         } else {
             $controllerID .= '/';
         }
         $className = ucfirst($id) . 'Controller';
         $classFile = $basePath . DIRECTORY_SEPARATOR . $className . '.php';
         $extendedClassFile = Yii::getCustomPath($basePath . DIRECTORY_SEPARATOR . 'My' . $className . '.php');
         if (is_file($extendedClassFile)) {
             // see if there's an extended controller in /custom
             if (!class_exists($className, false)) {
                 require Yii::getCustomPath($classFile);
             }
             // import the 'real' controller
             $className = 'My' . $className;
             // add "My" to the class name
             $classFile = $extendedClassFile;
         } else {
             $classFile = Yii::getCustomPath($classFile);
             // look in /custom for controller file
         }
         if (is_file($classFile)) {
             if (!class_exists($className, false)) {
                 require $classFile;
             }
             if (class_exists($className, false) && is_subclass_of($className, 'CController')) {
                 $id[0] = strtolower($id[0]);
                 return array(new $className($controllerID . $id, $owner === $this ? null : $owner), $this->parseActionParams($route));
             }
             return null;
         }
         $controllerID .= $id;
         $basePath .= DIRECTORY_SEPARATOR . $id;
     }
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:75,代码来源:X2WebApplication.php


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