本文整理汇总了PHP中Zend\ModuleManager\ModuleEvent::getModuleName方法的典型用法代码示例。如果您正苦于以下问题:PHP ModuleEvent::getModuleName方法的具体用法?PHP ModuleEvent::getModuleName怎么用?PHP ModuleEvent::getModuleName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\ModuleManager\ModuleEvent
的用法示例。
在下文中一共展示了ModuleEvent::getModuleName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __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;
}
示例2: __invoke
/**
* @param ModuleEvent $e
* @return object|false False if module class does not exist
*/
public function __invoke(ModuleEvent $e)
{
$moduleName = $e->getModuleName();
$class = $moduleName . '\\Module';
if (!class_exists($class)) {
return false;
}
return new $class();
}
示例3: __invoke
/**
* @param ModuleEvent $e
* @return object|false False if module class does not exist
*/
public function __invoke(ModuleEvent $e)
{
$moduleName = $e->getModuleName();
$class = $moduleName . '\\Module';
if (!class_exists($class)) {
// If expected module class was not found, check for the possible class name variations:
// - If module directory uses ZF1 naming style (spinal-case instead of CamelCase), check
// for Module class in Camel-Cased module name namespace
// - If that fails, check for class name prefixed with Camel-Cased module name
// (no autoloading involved here)
$moduleName = $this->formatModuleName($moduleName);
$class = $moduleName . '\\Module';
if (!class_exists($class)) {
$class = $moduleName . '_Module';
if (!class_exists($class, false)) {
return false;
}
}
}
$module = new $class();
return $module;
}
示例4: 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'];
}
}
}
}
}
示例5: 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;
}
示例6: 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;
}
}
示例7: 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;
}