2014-05-23 14 views
7

Tôi đã thiết lập một dự án mới với nhiều người quản lý thực thể, khi tôi cố gắng tải các đồ đạc dữ liệu, tôi nhận được một MappingException khi bàn điều khiển cố gắng tải Đồ đạc cho mọi thứ thay vì trình quản lý thực thể mà tôi đã chỉ định.Làm cách nào để sử dụng học thuyết Symfony: fixtures: tải với nhiều trình quản lý thực thể?

Đây là phần thuyết từ config.yml tôi

doctrine: 
    dbal: 
     connections: 
      default: 
       driver: %database_driver% 
       host:  %database_host% 
       port:  %database_port% 
       dbname: %database_name% 
       user:  %database_user% 
       password: %database_password% 
       charset: %database_charset% 
      symblog: 
       driver: %database_driver_blog% 
       host:  %database_host_blog% 
       port:  %database_port_blog% 
       dbname: %database_name_blog% 
       user:  %database_user_blog% 
       password: %database_password_blog% 
       charset: %database_charset_blog% 

    orm: 
     auto_generate_proxy_classes: %kernel.debug% 
     entity_managers: 
      default: 
       connection: default 
       mappings: 
        IncompassAuthBundle: ~ 
        IncompassUserBundle: ~ 
        IncompassApiBundle: ~ 
        IncompassSurgeryBundle: ~ 
        IncompassVendorBundle: ~ 
        IncompassHospitalBundle: ~ 
       dql: 
        datetime_functions: 
         date: Mapado\MysqlDoctrineFunctions\DQL\MysqlDate 
      symblog: 
       connection: symblog 
       mappings: 
        IncompassBlogBundle: ~ 
       dql: 
        datetime_functions: 
         date: Mapado\MysqlDoctrineFunctions\DQL\MysqlDate 

Như bạn có thể thấy tôi đã thiết lập một trình quản lý kết nối và thực thể riêng biệt cho những thứ hướng dẫn symblog.

Khi tôi cố gắng

php app/console doctrine:fixtures:load --em=default 

tôi có được điều này

Careful, database will be purged. Do you want to continue Y/N ?Y 
    > purging database 
    > loading [1] Incompass\BlogBundle\DataFixtures\ORM\BlogFixtures 

    [Doctrine\Common\Persistence\Mapping\MappingException]                            
    The class 'Incompass\BlogBundle\Entity\Blog' was not found in the chain configured namespaces Incompass\AuthBundle\Entity, Incompass\UserBundle\Entity, Incompass\ 
    SurgeryBundle\Entity, Incompass\VendorBundle\Entity, Incompass\HospitalBundle\Entity, FOS\UserBundle\Model               

doctrine:fixtures:load [--fixtures[="..."]] [--append] [--em="..."] [--purge-with-truncate] 

Khi tôi cố gắng

php app/console doctrine:fixtures:load --em=symblog 

tôi nhận được

Careful, database will be purged. Do you want to continue Y/N ?Y 
    > purging database 
    > loading [1] Incompass\BlogBundle\DataFixtures\ORM\BlogFixtures 
    > loading [1] Incompass\SurgeryBundle\DataFixtures\ORM\SurgeryStatusFixtures 

    [Doctrine\Common\Persistence\Mapping\MappingException]                     
    The class 'Incompass\SurgeryBundle\Entity\SurgeryStatus' was not found in the chain configured namespaces Incompass\BlogBundle\Entity 

doctrine:fixtures:load [--fixtures[="..."]] [--append] [--em="..."] [--purge-with-truncate] 

Vì vậy, lệnh giao diện điều khiển dường như bỏ qua tùy chọn "--em = foobar" và đang cố tải tất cả các đồ đạc dữ liệu mà nó tìm thấy.

Làm cách nào để nhận giáo lý: đồ đạc: tải chỉ để sử dụng trình quản lý thực thể được chỉ định?

+1

Tôi không nghĩ rằng nó sẽ để lọc đồ đạc bằng trình quản lý thực thể được cung cấp. Những gì bạn nên làm là chỉ định đường dẫn '--fixtures' – Phil

Trả lời

7

Sau Phils bình luận tôi chuyển tất cả các Đèn chiếu sáng của tôi vào một FixturesBundle và đã làm điều này

php app/console doctrine:fixtures:load --fixtures=src/Incompass/FixturesBundle/DataFixtures/ORM 

Đối với Lịch thi đấu Blog Tôi cũng đã phải chỉ định người quản lý thực thể

php app/console doctrine:fixtures:load --fixtures=src/Incompass/BlogBundle/DataFixtures/ORM --em=symblog 
Các vấn đề liên quan