2011-11-08 146 views
1

后,我试图自举 所有这些服务依赖于数据库Zend_Db的过程中设置了服务定位数据库适配器和每个服务注入了上创建所需的数据映射器。Zend公司创建之前或的Bootstrap

看起来有点像这样:

$alertService = new WORK_Alert_Service_Service(array("AlertMapper" => new Model_Alert_Mapper(), 
                  "AlertUserSubscriptionMapper" => new Model_Alert_User_Subscription_Mapper())); 

    $emailerService = new WORK_Emailer_Service_Service(
     array("AccountMapper" => new Model_Emailer_Email_Account_Mapper())); 

    $encryptionService = new WORK_Encryption_Service_Service(); 

    $services = array( 
     $alertService, 
     $emailerService, 
     $encryptionService 
    ); 

    WORK_ServiceLocator::regiserServices($services); 

因此,我发现的是,我得到以下错误

problemNo适配器发现Model_Emailer_DbTable_EmailAccounts

这是什么原因发生在电子邮件服务器上,但不是警报服务是 电子邮件服务器连接到数据库并获取所有可用的电子邮件帐户,并将它们存储在建筑以后使用的对象(维护映射对象,这样的帐户列表可以被操纵/清除,如果需要复位)。

是否Zend_Db的适配器获得引导过程后产生的? 如果是的话,是否有可能推动这一进展?

可我解决这个问题通过移动这些用于各个模块的引导文件?

回答

1

我试图自举

我假定然后,上面的代码中出现的自举_init*方法期间建立一个服务定位器。如果是这样,只要把这个在你的方法开始

protected function _initServices() 
{ 
    $this->bootstrap('db'); 

    // and the rest 

http://framework.zend.com/manual/en/zend.application.theory-of-operation.html#zend.application.theory-of-operation.bootstrap.dependency-tracking

+0

这正是我需要谢谢。 是的,你是正确的_init方法。 _init方法是否按照在引导程序中写入的顺序执行? – user966936

+0

它使用['get_class_method(0函数)'](http://php.net/manual/en/function.get-class-methods.php)在内部这似乎在声明的顺序返回它们。我不知道它是如何整合与资源插件,因此需要引导的依赖关系的洞察 – Phil

+0

十分感谢这个顺序。 – user966936