本文整理汇总了PHP中Zend\ModuleManager\ModuleEvent::getModule方法的典型用法代码示例。如果您正苦于以下问题:PHP ModuleEvent::getModule方法的具体用法?PHP ModuleEvent::getModule怎么用?PHP ModuleEvent::getModule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\ModuleManager\ModuleEvent
的用法示例。
在下文中一共展示了ModuleEvent::getModule方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onLoadModule
/**
* loadModule
*
* Check each loaded module to see if it implements LocatorRegistered. If it
* does, we add it to an internal array for later.
*
* @param ModuleEvent $e
* @return void
*/
public function onLoadModule(ModuleEvent $e)
{
if (!$e->getModule() instanceof LocatorRegisteredInterface) {
return;
}
$this->modules[] = $e->getModule();
}
示例2: __invoke
/**
* @param ModuleEvent $e
* @eturn void
*/
public function __invoke(ModuleEvent $e)
{
$module = $e->getModule();
if (!$module instanceof InitProviderInterface && !method_exists($module, 'init')) {
return;
}
$module->init($e->getTarget());
}
示例3: __invoke
/**
* @param ModuleEvent $e
* @return void
*/
public function __invoke(ModuleEvent $e)
{
$module = $e->getModule();
if (!$module instanceof AutoloaderProviderInterface && !method_exists($module, 'getAutoloaderConfig')) {
return;
}
$autoloaderConfig = $module->getAutoloaderConfig();
AutoloaderFactory::factory($autoloaderConfig);
}
示例4: __invoke
/**
* @param ModuleEvent $e
* @return void
*/
public function __invoke(ModuleEvent $e)
{
$module = $e->getModule();
if (!$module instanceof BootstrapListenerInterface && !method_exists($module, 'onBootstrap')) {
return;
}
$moduleManager = $e->getTarget();
$events = $moduleManager->getEventManager();
$sharedEvents = $events->getSharedManager();
$sharedEvents->attach('Zend\\Mvc\\Application', MvcEvent::EVENT_BOOTSTRAP, array($module, 'onBootstrap'));
}
示例5: __invoke
/**
* @param \Zend\ModuleManager\ModuleEvent $e
*
* @throws Exception\MissingDependencyModuleException
*/
public function __invoke(ModuleEvent $e)
{
$module = $e->getModule();
if ($module instanceof DependencyIndicatorInterface || method_exists($module, 'getModuleDependencies')) {
$dependencies = $module->getModuleDependencies();
foreach ($dependencies as $dependencyModule) {
if (!isset($this->loaded[$dependencyModule])) {
throw new Exception\MissingDependencyModuleException(sprintf('Module "%s" depends on module "%s", which was not initialized before it', $e->getModuleName(), $dependencyModule));
}
}
}
$this->loaded[$e->getModuleName()] = true;
}
示例6: onLoadModule
public function onLoadModule(ModuleEvent $e)
{
$module = $e->getModule();
if (!$module instanceof DirectoryProviderInterface && !method_exists($module, 'getDir')) {
return;
}
$moduleDirectory = $module->getDir();
if (!is_dir($moduleDirectory)) {
return;
}
// Store the module path
$moduleName = $e->getModuleName();
$this->paths[$moduleName] = array('path' => $moduleDirectory, 'template_path_stack' => null, 'default_template_path_stack' => null);
// Check for especific module-dependant themes
if ($module instanceof ConfigProviderInterface || is_callable(array($this, 'getConfig'))) {
$config = $module->getConfig();
if ($config instanceof Traversable) {
$config = ArrayUtils::iteratorToArray($config);
}
if (!is_array($config)) {
throw new Exception\InvalidArgumentException(sprintf('Config being merged must be an array, ' . 'implement the Traversable interface, or be an ' . 'instance of Zend\\Config\\Config. %s given.', gettype($config)));
}
if (isset($config['theme_manager'])) {
if (is_array($config['theme_manager'])) {
if (isset($config['theme_manager']['template_path_stack'])) {
$this->paths[$moduleName]['template_path_stack'] = $config['theme_manager']['template_path_stack'];
}
}
}
if (isset($config['view_manager'])) {
if (is_array($config['view_manager'])) {
if (isset($config['view_manager']['template_path_stack'])) {
$this->paths[$moduleName]['default_template_path_stack'] = $config['view_manager']['template_path_stack'];
}
}
}
}
}
示例7: onLoadModule
/**
* Merge the config for each module
*
* @param ModuleEvent $e
* @return ConfigListener
*/
public function onLoadModule(ModuleEvent $e)
{
$module = $e->getModule();
if (!$module instanceof ConfigProviderInterface && !is_callable(array($module, 'getConfig'))) {
return $this;
}
$config = $module->getConfig();
$this->addConfig($e->getModuleName(), $config);
return $this;
}
示例8: onLoadModule
/**
* Retrieve service manager configuration from module, and
* configure the service manager.
*
* If the module does not implement a specific interface and does not
* implement a specific method, does nothing. Also, if the return value
* of that method is not a ServiceConfig object, or not an array or
* Traversable that can seed one, does nothing.
*
* The interface and method name can be set by adding a new service manager
* via the addServiceManager() method.
*
* @param ModuleEvent $e
* @return void
*/
public function onLoadModule(ModuleEvent $e)
{
$module = $e->getModule();
foreach ($this->serviceManagers as $key => $sm) {
if (!$module instanceof $sm['module_class_interface'] && !method_exists($module, $sm['module_class_method'])) {
continue;
}
$config = $module->{$sm['module_class_method']}();
if ($config instanceof ServiceConfigInterface) {
$config = $this->serviceConfigToArray($config);
}
if ($config instanceof Traversable) {
$config = ArrayUtils::iteratorToArray($config);
}
if (!is_array($config)) {
// If we do not have an array by this point, nothing left to do.
continue;
}
// We are keeping track of which modules provided which configuration to which service managers.
// The actual merging takes place later. Doing it this way will enable us to provide more powerful
// debugging tools for showing which modules overrode what.
$fullname = $e->getModuleName() . '::' . $sm['module_class_method'] . '()';
$this->serviceManagers[$key]['configuration'][$fullname] = $config;
}
}
示例9: getServicesTrigger
/**
* Event callback for 'initServicesTrigger'.
*
* @param ModuleEvent $e
*
* @return $this
*/
public function getServicesTrigger(ModuleEvent $e)
{
$module = $e->getModule();
if (is_callable(array($module, 'getServiceConfig'))) {
$services = $module->getServiceConfig();
if (is_array($services) && isset($services['factories'])) {
$this->services[$e->getModuleName()] = $services['factories'];
}
}
return $this;
}
示例10: __invoke
/**
* @param \Zend\ModuleManager\ModuleEvent $e
*/
public function __invoke(ModuleEvent $e)
{
$module = $e->getModule();
echo get_class($module);
exit;
}
示例11: __invoke
/**
* @param ModuleEvent $e
* @return void
*/
public function __invoke(ModuleEvent $e)
{
$module = $e->getModule();
if (!$module instanceof ThemeProviderInterface && !method_exists($module, 'initTheme')) {
return;
}
$moduleManager = $e->getTarget();
$events = $moduleManager->getEventManager();
$sharedEvents = $events->getSharedManager();
$module_directory = $module->getDir();
$sharedEvents->attach('Zend\\Mvc\\Application', MvcEvent::EVENT_BOOTSTRAP, function ($e) use($module_directory) {
$application = $e->getApplication();
$eventManager = $application->getEventManager();
$serviceManager = $application->getServiceManager();
$themeManager = $serviceManager->get('ThemeManager');
$theme = $themeManager->getTheme();
$theme_folder = $theme->getFolder();
$theme_path = $module_directory . '/themes/' . $theme_folder;
if (!is_dir($theme_path)) {
$theme = $themeManager->getDefaultTheme();
$theme_folder = $theme->getFolder();
if (!is_dir($theme_path)) {
throw new MissingDefaultThemeException();
}
}
$theme_path = $module_directory . '/themes/' . $theme->getFolder();
// Views
// Add the folder to the template resolver.
$templatePathResolver = $serviceManager->get('Zend\\View\\Resolver\\TemplatePathStack');
$templatePathResolver->addPath($theme_path);
// Layout
if (file_exists($theme_path . '/layout.phtml')) {
$templateMapResolver = $serviceManager->get('Zend\\View\\Resolver\\TemplateMapResolver');
$layout_name = $theme->getLayoutName();
if (!$templateMapResolver->has($layout_name)) {
$templateMapResolver->add($layout_name, $theme_path . '/layout.phtml');
}
}
});
$sharedEvents->attach($module->getNamespace(), MvcEvent::EVENT_DISPATCH, function ($e) use($module_directory) {
// Set the layout for this module if available
$serviceManager = $e->getApplication()->getServiceManager();
$themeManager = $serviceManager->get('ThemeManager');
$theme = $themeManager->getTheme();
$theme_folder = $theme->getFolder();
$theme_path = $module_directory . '/themes/' . $theme_folder;
if (!is_dir($theme_path)) {
$theme = $themeManager->getDefaultTheme();
$theme_folder = $theme->getFolder();
if (!is_dir($theme_path)) {
throw new MissingDefaultThemeException();
}
}
$layout_name = $theme->getLayoutName();
$templateMapResolver = $serviceManager->get('Zend\\View\\Resolver\\TemplateMapResolver');
if ($templateMapResolver->has($layout_name)) {
$viewModel = $e->getViewModel();
$viewModel->setTemplate($layout_name);
}
}, 100);
}