本文整理匯總了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;
}
示例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);
}
示例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;
}