当我跟踪zf2中的代码时,我无法找到应用程序服务注册的地方。 这里是application.phpzf2中的loadModules.post是一个函数吗?
public static function init($configuration = array())
{
$smConfig = isset($configuration['service_manager']) ? $configuration['service_manager'] : array();
$serviceManager = new ServiceManager(new Service\ServiceManagerConfig($smConfig));
$serviceManager->setService('ApplicationConfig', $configuration);
$serviceManager->get('ModuleManager')->loadModules();
return $serviceManager->get('Application')->bootstrap();
}
代码 “$ serviceManager-> GET( '应用')” 的代码是让应用程序服务。但是应用服务注册在哪里?
然后我发现Application服务与ZF2/library中的代码行“$ this-> getEventManager() - >触发器(ModuleEvent :: EVENT_LOAD_MODULES_POST,$ this,$ this-> getEvent())”相关/Zend/MoudleManager/MoudleManager.php
public function loadModules()
{
if (true === $this->modulesAreLoaded) {
return $this;
}
$this->getEventManager()->trigger(ModuleEvent::EVENT_LOAD_MODULES, $this, $this->getEvent());
/**
* Having a dedicated .post event abstracts the complexity of priorities from the user.
* Users can attach to the .post event and be sure that important
* things like config merging are complete without having to worry if
* they set a low enough priority.
*/
$this->getEventManager()->trigger(ModuleEvent::EVENT_LOAD_MODULES_POST, $this, $this->getEvent());
return $this;
}
的另一个问题是,“ModuleEvent :: EVENT_LOAD_MODULES_POST,这是触发功能的loadModules.post.The第一个参数是一个函数名,所以是loadModules.post一个函数?在哪里定义的?
在此先感谢。
谢谢马修,我明白了。并感谢yechabbi。 – Leo