2013-12-08 120 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模块没有正确安装,或者没有安装。