zend framework 2 + doctrine 2 + DoctrineDataFixture模块没有加载灯具

时间:2013-08-02 16:40:26

标签: php doctrine zend-framework2

你好zend framework 2 + doctrine2和DoctrineDataFixtureModule(https://github.com/Hounddog/DoctrineDataFixtureModule)有些问题 模块没有加载我的灯具 这是我的配置

'doctrine' => array(
    'eventmanager' => array(
        'orm_default' => array(
            'subscribers' => array(

                'Gedmo\Tree\TreeListener',
                'Gedmo\Timestampable\TimestampableListener',
                'Gedmo\Sluggable\SluggableListener',
                'Gedmo\Loggable\LoggableListener',
                'Gedmo\Sortable\SortableListener'
            ),
        ),
    ),
     'driver' => array(

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

            )
          'data-fixture' => array(
             __NAMESPACE__.'_fixture' =>  __DIR__ . '/../src/'.__NAMESPACE__.'/Fixtures',
          ),
        ),

        'translatable_metadata_driver' => array(
            'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
            'cache' => 'array',
            'paths' => array(
                'vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity',
            ),
        ),
        'orm_default' => array(
          'drivers' => array(
            __NAMESPACE__.'\Entity' => __NAMESPACE__.'_driver',
          //  'Gedmo\Translatable\Entity' => 'translatable_metadata_driver',
          )
        ),
    )

), 问题是我不知道如何设置灯具路径或数组中的确切键,我必须设置灯具路径 在开发人员说的文档中:

  

要使用Doctrine模块注册驱动程序,只需将驱动程序添加到   您的配置中的doctrine.driver键。

return array(
'data-fixture' => array(
    'ModuleName_fixture' => __DIR__ . '/../src/ModuleName/Fixture',
),

);

1 个答案:

答案 0 :(得分:2)

实际上,您需要将data-fixture数组添加到doctrine数组中配置数组的根目录 not 。像这样:

return array(
...
    'doctrine' => array(
        'eventmanager' => array(
            'orm_default' => array(
                'subscribers' => array(

                    'Gedmo\Tree\TreeListener',
                    'Gedmo\Timestampable\TimestampableListener',
                    'Gedmo\Sluggable\SluggableListener',
                    'Gedmo\Loggable\LoggableListener',
                    'Gedmo\Sortable\SortableListener'
                ),
            ),
        ),
        'driver' => array(

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

                )
            ),

            'translatable_metadata_driver' => array(
                'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
                'cache' => 'array',
                'paths' => array(
                    'vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity',
                ),
            ),
            'orm_default' => array(
                'drivers' => array(
                    __NAMESPACE__.'\Entity' => __NAMESPACE__.'_driver',
//  'Gedmo\Translatable\Entity' => 'translatable_metadata_driver',
                )
            ),
        )
    ),
    'data-fixture' => array(
        __NAMESPACE__.'_fixture' =>  __DIR__ . '/../src/'.__NAMESPACE__.'/Fixtures',
    ),
...
);

我承认文档中的措辞有点令人困惑。