當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Module::getModules方法代碼示例

本文整理匯總了PHP中yii\base\Module::getModules方法的典型用法代碼示例。如果您正苦於以下問題:PHP Module::getModules方法的具體用法?PHP Module::getModules怎麽用?PHP Module::getModules使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yii\base\Module的用法示例。


在下文中一共展示了Module::getModules方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getRouteRecrusive

 /**
  * 
  * @param \yii\base\Module $module
  * @param array $result
  */
 private static function getRouteRecrusive($module, &$result)
 {
     foreach ($module->getModules() as $id => $child) {
         if (($child = $module->getModule($id)) !== null) {
             self::getRouteRecrusive($child, $result);
         }
     }
     /* @var $controller \yii\base\Controller */
     foreach ($module->controllerMap as $id => $value) {
         $controller = Yii::createObject($value, [$id, $module]);
         self::getActionRoutes($controller, $result);
         $result[] = '/' . $controller->uniqueId . '/*';
     }
     $namespace = trim($module->controllerNamespace, '\\') . '\\';
     self::getControllerRoutes($module, $namespace, '', $result);
     $result[] = ($module->uniqueId === '' ? '' : '/' . $module->uniqueId) . '/*';
 }
開發者ID:hscstudio,項目名稱:yii2-heart,代碼行數:22,代碼來源:AccessHelper.php

示例2: getModuleCommands

 /**
  * Returns available commands of a specified module.
  * @param \yii\base\Module $module the module instance
  * @return array the available command names
  */
 protected function getModuleCommands($module)
 {
     $prefix = $module instanceof Application ? '' : $module->getUniqueId() . '/';
     $commands = [];
     foreach (array_keys($module->controllerMap) as $id) {
         $commands[] = $prefix . $id;
     }
     foreach ($module->getModules() as $id => $child) {
         if (($child = $module->getModule($id)) === null) {
             continue;
         }
         foreach ($this->getModuleCommands($child) as $command) {
             $commands[] = $command;
         }
     }
     $controllerPath = $module->getControllerPath();
     if (is_dir($controllerPath)) {
         $files = scandir($controllerPath);
         foreach ($files as $file) {
             if (!empty($file) && substr_compare($file, 'Controller.php', -14, 14) === 0) {
                 $controllerClass = $module->controllerNamespace . '\\' . substr(basename($file), 0, -4);
                 if ($this->validateControllerClass($controllerClass)) {
                     $commands[] = $prefix . Inflector::camel2id(substr(basename($file), 0, -14));
                 }
             }
         }
     }
     return $commands;
 }
開發者ID:drodata,項目名稱:yii2,代碼行數:34,代碼來源:HelpController.php

示例3: getModuleCommands

 /**
  * Returns available commands of a specified module.
  * @param \yii\base\Module $module the module instance
  * @return array the available command names
  */
 protected function getModuleCommands($module)
 {
     $prefix = $module instanceof Application ? '' : $module->getUniqueID() . '/';
     $commands = [];
     foreach (array_keys($module->controllerMap) as $id) {
         $commands[] = $prefix . $id;
     }
     foreach ($module->getModules() as $id => $child) {
         if (($child = $module->getModule($id)) === null) {
             continue;
         }
         foreach ($this->getModuleCommands($child) as $command) {
             $commands[] = $command;
         }
     }
     $controllerPath = $module->getControllerPath();
     if (is_dir($controllerPath)) {
         $files = scandir($controllerPath);
         foreach ($files as $file) {
             if (strcmp(substr($file, -14), 'Controller.php') === 0) {
                 $commands[] = $prefix . Inflector::camel2id(substr(basename($file), 0, -14));
             }
         }
     }
     return $commands;
 }
開發者ID:davidpersson,項目名稱:FrameworkBenchmarks,代碼行數:31,代碼來源:HelpController.php

示例4: configure

 /**
  * Configures given module with provided configuration array.
  * @param \yii\base\Module $module module to be configured.
  * @param array $config configuration array.
  */
 public function configure($module, $config = null)
 {
     if ($config === null) {
         $config = $this->fetchConfig();
     }
     foreach ($config as $key => $value) {
         switch ($key) {
             case 'components':
                 $components = array_merge($module->getComponents(true), $module->getComponents(false));
                 $components = ArrayHelper::merge($components, $value);
                 $module->setComponents($components);
                 break;
             case 'modules':
                 $nestedModules = $module->getModules(false);
                 foreach ($nestedModules as $id => $nestedModule) {
                     if (!isset($value[$id])) {
                         continue;
                     }
                     if (is_object($nestedModule)) {
                         $this->configure($nestedModule, $value[$id]);
                     } else {
                         $nestedModules[$id] = ArrayHelper::merge($nestedModule, $value[$id]);
                     }
                 }
                 $module->setModules($nestedModules);
                 break;
             case 'params':
                 $module->params = ArrayHelper::merge($module->params, $value);
                 break;
             default:
                 $module->{$key} = $value;
         }
     }
 }
開發者ID:heartshare,項目名稱:config,代碼行數:39,代碼來源:Manager.php

示例5: getRouteRecrusive

 /**
  * 
  * @param \yii\base\Module $module
  * @param array $result
  */
 private static function getRouteRecrusive($module, &$result, $exclude)
 {
     foreach ($module->getModules() as $id => $child) {
         if (($child = $module->getModule($id)) !== null) {
             if (!in_array($child->id, $exclude['module'])) {
                 self::getRouteRecrusive($child, $result, $exclude);
             }
         }
     }
     /* @var $controller \yii\base\Controller */
     foreach ($module->controllerMap as $id => $value) {
         $controller = Yii::createObject($value, [$id, $module]);
         if (!in_array($controller->module->id, $exclude['module']) && !in_array($controller->id, $exclude['controller'])) {
             self::getActionRoutes($controller, $result);
             //$result[$controller->module->id][$controller->id][] = '*';
             //$result['map'][$controller->module->id]['*'][] = '*';
             /*
                             $result['map'][] = [
                                 'module' => $controller->module->id,
                                 'controller' => $controller->id,
                                 'action'    =>  '*',
                             ];
                             //*/
         }
     }
     if (!in_array($module->id, $exclude['module'])) {
         $namespace = trim($module->controllerNamespace, '\\') . '\\';
         self::getControllerRoutes($module, $namespace, '', $result, $exclude);
         //$result[$module->id]['*'] = '*';
         //$result['map'][$controller->module->id]['*'][] = '*';
         /*
                     $result['model'][] = [
                             'module' => $module->id,
                             'controller' => '*',
                             'action'    =>  '*',
                         ];
                     //*/
     }
 }
開發者ID:highestgoodlikewater,項目名稱:yii2-metadata,代碼行數:44,代碼來源:MetaData.php


注:本文中的yii\base\Module::getModules方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。