2013-12-08 119 views
1

在我將驗證服務名稱從'orm_default'更改爲'admin'之前,它已成功工作,並且有必要,因爲我有更多使用更多驗證服務的模塊。Zend Framework 2 + Doctrine 2和驗證服務

的問題是,我發現了以下錯誤:

Fatal error: Uncaught exception 'Zend\ServiceManager\Exception\ServiceNotFoundException' with message 'Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for doctrine.authenticationservice.admin' 

我module.config.php

'doctrine' => array 
(

'driver' => array 
(

    __NAMESPACE__ . '_driver' => array 
    (

     'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver', 
     'cache' => 'array', 
     'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Entity') 

    ), 

    'orm_default' => array 
    (

     'drivers' => array 
     (

      __NAMESPACE__ . '\Entity' => __NAMESPACE__ . '_driver' 

     ), 



    ) 

), 

'authentication' => array 
(

    'admin' => array 
    (

     'object_manager' => 'Doctrine\ORM\EntityManager', 
     'identity_class' => __NAMESPACE__ . '\Entity\User', 
     'identity_property' => 'email', 
     'credential_property' => 'password', 
     'credentialCallable' => __NAMESPACE__ . '\Model\User::hashPassword' 

    ), 

), 

), 

我Module.php

public function getServiceConfig() 
{ 
    return array 
    (
     'factories' => array 
     (

      'Admin\Auth' => function($sm) 
      { 

       return $sm->get('doctrine.authenticationservice.admin'); 

      }, 

      'Admin\Form\Auth\Login' => function($sm) 
      { 

       return new Form\Auth\Login(); 

      }, 

     ), 

    ); 
} 
+0

你實際上使用了DoctrineModule和DoctrineORMModule的0.8嗎? – Ocramius

+0

@Ocramius:沒有。我正在使用0.7.x.我在我的composer.json中更改爲0.8.x,但它說版本0.8.x中沒有doctrine-orm-module。 – rafaame

+0

@Ocramius:好吧,我將我的composer.json更新爲dev-master,但我仍然得到相同的錯誤:帶有消息'Zend \ ServiceManager \ ServiceManager :: get'的未捕獲異常'Zend \ ServiceManager \ Exception \ ServiceNotFoundException'無法獲取或爲doctrine.authenticationservice.admin創建一個實例'。 – rafaame

回答

2

它被確認爲一個bug:https://github.com/doctrine/DoctrineORMModule/issues/291

根據教條模塊源文件中的評論,它計劃在1.0中進行修復。在此期間,你可以在你的應用程序的任何的文件module.config.php像這樣:

'authentication' => 
    [ 

     'application' => 
     [ 

      'object_manager' => 'Doctrine\ORM\EntityManager', 
      'identity_class' => 'Application\Entity\Customer', 
      'identity_property' => 'email', 
      'credential_property' => 'password', 
      'credentialCallable' => 'Application\Entity\Customer::hashPassword' 

     ], 

    ], 

    'authenticationadapter' => 
    [ 

     'application' => true, 

    ], 

    'authenticationstorage' => 
    [ 

     'application' => true, 

    ], 

    'authenticationservice' => 
    [ 

     'application' => true, 
    ] 
0

我有完全相同的問題,當我正在我的項目。在我的* ss出了兩晚之後,我通過在閱讀https://github.com/doctrine/DoctrineORMModule「註冊服務名稱」部分後重新安裝doctrine-orm-module來解決了問題。這僅僅意味着doctrine orm模塊沒有正確安裝,或者沒有安裝。