yii\base\Module::getControllerPath PHP Method

getControllerPath() public method

Note that in order for this method to return a value, you must define an alias for the root namespace of [[controllerNamespace]].
public getControllerPath ( ) : string
return string the directory that contains the controller classes.
    public function getControllerPath()
    {
        return Yii::getAlias('@' . str_replace('\\', '/', $this->controllerNamespace));
    }

Usage Example

Beispiel #1
0
 /**
  * @param Module $module
  *
  * @return array
  */
 public function getModuleControllers(Module $module)
 {
     $controllers = [];
     $path = $module->getControllerPath();
     $files = array_diff(scandir($path), ['..', '.']);
     asort($files);
     foreach ($files as $file) {
         if (strcmp(mb_substr($file, -mb_strlen(self::CONTROLLER_FILE)), self::CONTROLLER_FILE) === 0) {
             $id = Inflector::camel2id(mb_substr(basename($file), 0, -mb_strlen(self::CONTROLLER_FILE)));
             $controller = $this->getModuleController($module, $id);
             if ($controller) {
                 $controllers[$id] = $this->getControllerActions($controller);
             }
         }
     }
     return $controllers;
 }
All Usage Examples Of yii\base\Module::getControllerPath