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


PHP ModuleManagerInterface::getLoadedModules方法代码示例

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


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

示例1: init

 /**
  * Ensure the UI module is loaded
  *
  * @param ModuleManagerInterface $modules
  */
 public function init(ModuleManagerInterface $modules)
 {
     $loaded = $modules->getLoadedModules();
     if (isset($loaded['ZF\\Apigility\\Admin\\Ui'])) {
         return;
     }
     $modules->loadModule('ZF\\Apigility\\Admin\\Ui');
 }
开发者ID:alapini,项目名称:apigility-3hr-tutorial,代码行数:13,代码来源:Module.php

示例2: init

 /**
  * Initialize module.
  *
  * If the admin UI module is not loaded yet, load it.
  *
  * Disable the opcache as well.
  *
  * @param ModuleManagerInterface $modules
  */
 public function init(ModuleManagerInterface $modules)
 {
     $loaded = $modules->getLoadedModules(false);
     if (!isset($loaded['ZF\\Apigility\\Admin\\Ui'])) {
         $modules->loadModule('ZF\\Apigility\\Admin\\Ui');
     }
     $this->disableOpCache();
 }
开发者ID:zfcampus,项目名称:zf-apigility-admin,代码行数:17,代码来源:Module.php

示例3: getConsoleUsage

 /**
  * Build Console usage information by querying currently loaded modules.
  *
  * @param ConsoleAdapter         $console
  * @param string                 $scriptName
  * @param ModuleManagerInterface $moduleManager
  * @return string
  * @throws RuntimeException
  */
 protected function getConsoleUsage(ConsoleAdapter $console, $scriptName, ModuleManagerInterface $moduleManager = null)
 {
     /*
      * Loop through all loaded modules and collect usage info
      */
     $usageInfo = array();
     if ($moduleManager !== null) {
         foreach ($moduleManager->getLoadedModules(false) as $name => $module) {
             // Strict-type on ConsoleUsageProviderInterface, or duck-type
             // on the method it defines
             if (!$module instanceof ConsoleUsageProviderInterface && !method_exists($module, 'getConsoleUsage')) {
                 continue;
                 // this module does not provide usage info
             }
             // We prepend the usage by the module name (printed in red), so that each module is
             // clearly visible by the user
             $moduleName = sprintf("%s\n%s\n%s\n", str_repeat('-', $console->getWidth()), $name, str_repeat('-', $console->getWidth()));
             $moduleName = $console->colorize($moduleName, ColorInterface::RED);
             $usage = $module->getConsoleUsage($console);
             // Normalize what we got from the module or discard
             if (is_array($usage) && !empty($usage)) {
                 array_unshift($usage, $moduleName);
                 $usageInfo[$name] = $usage;
             } elseif (is_string($usage) && $usage != '') {
                 $usageInfo[$name] = array($moduleName, $usage);
             }
         }
     }
     /*
      * Handle an application with no usage information
      */
     if (!count($usageInfo)) {
         // TODO: implement fetching available console routes from router
         return '';
     }
     /*
      * Transform arrays in usage info into columns, otherwise join everything together
      */
     $result = '';
     $table = false;
     $tableCols = 0;
     $tableType = 0;
     foreach ($usageInfo as $moduleName => $usage) {
         if (!is_string($usage) && !is_array($usage)) {
             throw new RuntimeException(sprintf('Cannot understand usage info for module "%s"', $moduleName));
         }
         if (is_string($usage)) {
             // It's a plain string - output as is
             $result .= $usage . "\n";
             continue;
         }
         // It's an array, analyze it
         foreach ($usage as $a => $b) {
             /*
              * 'invocation method' => 'explanation'
              */
             if (is_string($a) && is_string($b)) {
                 if (($tableCols !== 2 || $tableType != 1) && $table !== false) {
                     // render last table
                     $result .= $this->renderTable($table, $tableCols, $console->getWidth());
                     $table = false;
                     // add extra newline for clarity
                     $result .= "\n";
                 }
                 // Colorize the command
                 $a = $console->colorize($scriptName . ' ' . $a, ColorInterface::GREEN);
                 $tableCols = 2;
                 $tableType = 1;
                 $table[] = array($a, $b);
                 continue;
             }
             /*
              * array('--param', '--explanation')
              */
             if (is_array($b)) {
                 if ((count($b) != $tableCols || $tableType != 2) && $table !== false) {
                     // render last table
                     $result .= $this->renderTable($table, $tableCols, $console->getWidth());
                     $table = false;
                     // add extra newline for clarity
                     $result .= "\n";
                 }
                 $tableCols = count($b);
                 $tableType = 2;
                 $table[] = $b;
                 continue;
             }
             /*
              * 'A single line of text'
              */
             if ($table !== false) {
//.........这里部分代码省略.........
开发者ID:leonardovn86,项目名称:zf2_basic2013,代码行数:101,代码来源:RouteNotFoundStrategy.php

示例4: getConsoleUsage

 /**
  * Build Console usage information by querying currently loaded modules.
  *
  * @param ConsoleAdapter         $console
  * @param string                 $scriptName
  * @param ModuleManagerInterface $moduleManager
  * @return string
  * @throws RuntimeException
  */
 protected function getConsoleUsage(ConsoleAdapter $console, $scriptName, ModuleManagerInterface $moduleManager = null)
 {
     /**
      * Loop through all loaded modules and collect usage info
      */
     $usageInfo = array();
     if ($moduleManager !== null) {
         foreach ($moduleManager->getLoadedModules(false) as $name => $module) {
             if (!$module instanceof ConsoleUsageProviderInterface) {
                 continue;
                 // this module does not provide usage info
             }
             /* @var $module ConsoleUsageProviderInterface */
             $usage = $module->getConsoleUsage($console);
             // Normalize what we got from the module or discard
             if (is_array($usage)) {
                 $usageInfo[$name] = $usage;
             } elseif (is_string($usage)) {
                 $usageInfo[$name] = array($usage);
             }
         }
     }
     /**
      * Handle an application with no usage information
      */
     if (!count($usageInfo)) {
         // TODO: implement fetching available console routes from router
         return '';
     }
     /**
      * Transform arrays in usage info into columns, otherwise join everything together
      */
     $result = '';
     $table = false;
     $tableCols = 0;
     $tableType = 0;
     foreach ($usageInfo as $moduleName => $usage) {
         if (is_string($usage)) {
             // It's a plain string - output as is
             $result .= $usage . "\n";
         } elseif (is_array($usage)) {
             // It's an array, analyze it
             foreach ($usage as $a => $b) {
                 if (is_string($a) && is_string($b)) {
                     /**
                      *    'ivocation method' => 'explanation'
                      */
                     if (($tableCols !== 2 || $tableType != 1) && $table !== false) {
                         // render last table
                         $result .= $this->renderTable($table, $tableCols, $console->getWidth());
                         $table = false;
                         // add extra newline for clarity
                         $result .= "\n";
                     }
                     $tableCols = 2;
                     $tableType = 1;
                     $table[] = array($scriptName . ' ' . $a, $b);
                 } elseif (is_array($b)) {
                     /**
                      *  array( '--param', '--explanation' )
                      */
                     if ((count($b) != $tableCols || $tableType != 2) && $table !== false) {
                         // render last table
                         $result .= $this->renderTable($table, $tableCols, $console->getWidth());
                         $table = false;
                         // add extra newline for clarity
                         $result .= "\n";
                     }
                     $tableCols = count($b);
                     $tableType = 2;
                     $table[] = $b;
                 } else {
                     /**
                      *    'A single line of text'
                      */
                     if ($table !== false) {
                         // render last table
                         $result .= $this->renderTable($table, $tableCols, $console->getWidth());
                         $table = false;
                         // add extra newline for clarity
                         $result .= "\n";
                     }
                     $tableType = 0;
                     $result .= $b . "\n";
                 }
             }
         } else {
             throw new RuntimeException('Cannot understand usage info for module ' . $moduleName);
         }
     }
     // Finish last table
//.........这里部分代码省略.........
开发者ID:haoyanfei,项目名称:zf2,代码行数:101,代码来源:RouteNotFoundStrategy.php


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