本文整理汇总了PHP中Zend\ModuleManager\ModuleManagerInterface::getModules方法的典型用法代码示例。如果您正苦于以下问题:PHP ModuleManagerInterface::getModules方法的具体用法?PHP ModuleManagerInterface::getModules怎么用?PHP ModuleManagerInterface::getModules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\ModuleManager\ModuleManagerInterface
的用法示例。
在下文中一共展示了ModuleManagerInterface::getModules方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initLayout
/**
* Init layout
*/
protected function initLayout()
{
try {
// get a custom template path resolver
$templatePathResolver = $this->serviceLocator->get('Layout\\View\\Resolver\\TemplatePathStack');
// replace the default template path stack resolver with one
$aggregateResolver = $this->serviceLocator->get('Zend\\View\\Resolver\\AggregateResolver');
$aggregateResolver->attach($templatePathResolver)->getIterator()->remove($this->serviceLocator->get('Zend\\View\\Resolver\\TemplatePathStack'));
$layout = $this->serviceLocator->get('Application\\Model\\ModelManager')->getInstance('Layout\\Model\\LayoutBase');
$request = $this->serviceLocator->get('Request');
// get a layout from cookies
$allowSelectLayouts = (int) SettingService::getSetting('layout_select');
$cookieLayout = isset($request->getCookie()->{self::LAYOUT_COOKIE}) && $allowSelectLayouts ? (int) $request->getCookie()->{self::LAYOUT_COOKIE} : null;
// init a user selected layout
if ($cookieLayout) {
$activeLayouts = $layout->getLayoutsById($cookieLayout);
} else {
$activeLayouts = !empty(UserIdentityService::getCurrentUserIdentity()['layout']) && $allowSelectLayouts ? $layout->getLayoutsById(UserIdentityService::getCurrentUserIdentity()['layout']) : $layout->getDefaultActiveLayouts();
}
// add layouts paths for each module
foreach ($this->moduleManager->getModules() as $module) {
foreach ($activeLayouts as $layoutInfo) {
$templatePathResolver->addPath('module/' . $module . '/view/' . $layoutInfo['name']);
}
}
LayoutService::setCurrentLayouts($activeLayouts);
} catch (Exception $e) {
ApplicationErrorLogger::log($e);
}
}
示例2: init
/**
* @param ModuleManagerInterface $manager
*/
public function init(ModuleManagerInterface $manager)
{
$loadModules = $manager->getModules();
$adminModules = ['DoctrineModule', 'DoctrineORMModule', 'TwbBundle'];
$addModules = [];
foreach ($adminModules as $adminModule) {
if (!in_array($adminModule, $loadModules)) {
$addModules[] = $adminModule;
}
}
$manager->setModules(array_merge($addModules, $loadModules));
}