2014-05-12 68 views
1

對於我的系統中的兩個實體(「鏈接」和「聯繫人」),我是setting up an admin,但是當我導入第二個admin.yml文件時,我遇到問題。這是我的工作config.ymlSymfony路由在導入多個yaml文件時丟失

imports: 
    - { resource: parameters.yml } 
    - { resource: security.yml } 
    - { resource: @AyrshireMinisContactBundle/Resources/config/admin.yml } 

然而,當我加入這行只是下面我失去連接到AyrshireMinisContactBundle的所有路由,讓我引發的錯誤無數的(本質上說,擊潰了聯繫包無法找到):

- { resource: @AyrshireMinisCommonBundle/Resources/config/admin.yml } 

我如何配置我的config.yml,以允許在被拉到這些實體均爲admin文件?

錯誤:

CRITICAL - Uncaught PHP Exception Twig_Error_Runtime: "An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "admin_ayrshireminis_contact_contact_create" as such route does not exist.") in "SonataAdminBundle:Block:block_admin_list.html.twig" at line 39."

+4

使用config.yml導入路由而不是routing.yml的任何特定原因? – pmmaga

+0

@PedroMM我正在學習本教程(http://sonata-project.org/bundles/admin/master/doc/reference/getting_started.html#importing-it-in-the-main-config-yml)出於某種原因索納塔建議將其加載到'config.yml'中。 'admin.yml'文件不僅僅保存路由,還有其他配置設置。任何想法,爲什麼我失去了路線? – crmpicco

回答

1

我發現,這是由於不必在admin.yml兩個包一個正確命名服務造成的。

當我得到我sonata.admin.post組兩個「聯繫人」和「鏈接」的實體錯誤,但重命名這些如下我imports下第二個條目後工作一種享受。

聯繫admin.yml:

services: 
    sonata.contact.admin.post: # <-- line changed 
     class: AyrshireMinis\ContactBundle\Admin\ContactAdmin 
     tags: 
      - { name: sonata.admin, manager_type: orm, group: "Leads", label: "Contacts" } 
     arguments: 
      - ~ 
      - AyrshireMinis\ContactBundle\Entity\Contact 
      - ~ 
     calls: 
      - [ setTranslationDomain, [AyrshireMinisContactBundle]] 

鏈接admin.yml:

services: 
    sonata.link.admin.post: # <-- line changed 
     class: AyrshireMinis\CommonBundle\Admin\LinkAdmin 
     tags: 
      - { name: sonata.admin, manager_type: orm, group: "Links", label: "Links" } 
     arguments: 
      - ~ 
      - AyrshireMinis\CommonBundle\Entity\Link 
      - ~ 
     calls: 
      - [ setTranslationDomain, [AyrshireMinisCommonBundle]] 

HTH有人在未來。 Further reading