Пример #1
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     $this->searchClass = Module::getInstance()->searchClass;
     $this->idField = Module::getInstance()->idField;
     $this->usernameField = Module::getInstance()->usernameField;
     $this->userClassName = Module::getInstance()->userClassName;
     if ($this->userClassName === null) {
         $this->userClassName = Yii::$app->getUser()->identityClass;
         $this->userClassName = $this->userClassName ?: 'common\\models\\User';
     }
 }
Пример #2
0
 /**
  * @title 取得方法
  */
 private function _getMethods()
 {
     // 在配置中添加的要接受控制的命名空间
     $namespaces = Module::getInstance()->allowNamespaces;
     // 不接受控制的 module
     $ignoreModules = Module::getInstance()->ignoreModules;
     if (!$namespaces) {
         $modules = Yii::$app->getModules();
         foreach ($modules as $k => $v) {
             if (!in_array($k, $ignoreModules)) {
                 $mod = Yii::$app->getModule($k);
                 $namespace = str_replace('/', '\\', $mod->controllerNamespace);
                 array_push($namespaces, $namespace);
             }
         }
         //当前所在命名空间的控制器
         $currentNamespace = str_replace('/', '\\', \Yii::$app->controllerNamespace);
         array_push($namespaces, $currentNamespace);
     }
     //获取类方法
     $actions = (new Files())->getAllMethods($namespaces);
     return $actions;
 }