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


PHP ModuleManager::getModule方法代碼示例

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


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

示例1: createApiList

 /**
  * Create list of available API modules
  *
  * @return array
  */
 public function createApiList()
 {
     $apigilityModules = [];
     $q = preg_quote('\\');
     foreach ($this->moduleManager->getModules() as $moduleName) {
         $module = $this->moduleManager->getModule($moduleName);
         if ($module instanceof ApigilityProviderInterface) {
             $versionRegex = '#' . preg_quote($moduleName) . $q . 'V(?P<version>[^' . $q . ']+)' . $q . '#';
             $versions = [];
             $serviceConfigs = [];
             if ($this->config['zf-rest']) {
                 $serviceConfigs = array_merge($serviceConfigs, $this->config['zf-rest']);
             }
             if ($this->config['zf-rpc']) {
                 $serviceConfigs = array_merge($serviceConfigs, $this->config['zf-rpc']);
             }
             foreach ($serviceConfigs as $serviceName => $serviceConfig) {
                 if (!preg_match($versionRegex, $serviceName, $matches)) {
                     continue;
                 }
                 $version = $matches['version'];
                 if (!in_array($version, $versions)) {
                     $versions[] = $version;
                 }
             }
             $apigilityModules[] = ['name' => $moduleName, 'versions' => $versions];
         }
     }
     return $apigilityModules;
 }
開發者ID:zfcampus,項目名稱:zf-apigility-documentation,代碼行數:35,代碼來源:ApiFactory.php

示例2: testCanLoadMultipleModules

 public function testCanLoadMultipleModules()
 {
     $configListener = $this->defaultListeners->getConfigListener();
     $moduleManager = new ModuleManager(array('BarModule', 'BazModule'));
     $moduleManager->getEventManager()->attachAggregate($this->defaultListeners);
     $moduleManager->loadModules();
     $loadedModules = $moduleManager->getLoadedModules();
     $this->assertInstanceOf('BarModule\\Module', $loadedModules['BarModule']);
     $this->assertInstanceOf('BazModule\\Module', $loadedModules['BazModule']);
     $this->assertInstanceOf('BarModule\\Module', $moduleManager->getModule('BarModule'));
     $this->assertInstanceOf('BazModule\\Module', $moduleManager->getModule('BazModule'));
     $this->assertNull($moduleManager->getModule('NotLoaded'));
     $config = $configListener->getMergedConfig();
     $this->assertSame('foo', $config->bar);
     $this->assertSame('bar', $config->baz);
 }
開發者ID:nieldm,項目名稱:zf2,代碼行數:16,代碼來源:ModuleManagerTest.php

示例3: getPublicPath

 /**
  * Get the public path to the assets for a given module.
  *
  * We assume assets are stored in the <module-root>/public/ directory.
  * If not, the module can implement the <code>getPublicPath()</code>
  * method that returns the actual public path.
  *
  * @param string $moduleName
  * @return bool|string
  * @throws RuntimeException
  */
 protected function getPublicPath($moduleName)
 {
     $module = $this->modules->getModule($moduleName);
     if (!$module) {
         throw new RuntimeException("Module does not exist ({$moduleName})");
     }
     if (method_exists($module, 'getPublicPath')) {
         $public = rtrim($module->getPublicPath(), '/');
     } elseif (method_exists($module, 'getRootPath')) {
         $public = $module->getRootPath() . '/public';
     } elseif (method_exists($module, 'getPath')) {
         $public = $module->getPath() . '/../../public';
     } else {
         $ref = new ReflectionClass($module);
         $path = dirname($ref->getFileName());
         $public = realpath($path . '/../../public');
     }
     if (is_dir($public)) {
         return $public;
     }
     return false;
 }
開發者ID:radnan,項目名稱:rdn-asset,代碼行數:33,代碼來源:Publish.php


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