2016-11-10 78 views
0

我已經使用kunstmaan/adminlist-bundle生成了2個管理列表,並發現在routing.yml中指定的前綴無法識別。symfont路由前綴不起作用

MyBundle /資源/配置/ routing.yml中

appbundle_importerror_admin_list: 
    resource: @AppBundle/Controller/ImportErrorAdminListController.php 
    type:  annotation 
    prefix: /admin/importerror 

appbundle_filetosync_admin_list: 
    resource: @AppBundle/Controller/FileToSyncAdminListController.php 
    type:  annotation 
    prefix: /admin/filetosync/ 

然而,當我運行斌/控制檯調試:路由器,我得到

homepage        ANY  ANY  ANY /         
appbundle_admin_filetosync    ANY  ANY  ANY /         
appbundle_admin_filetosync_add   GET|POST ANY  ANY /add        
appbundle_admin_filetosync_edit   GET|POST ANY  ANY /{id}        
appbundle_admin_filetosync_view   GET  ANY  ANY /{id}        
appbundle_admin_filetosync_delete  GET|POST ANY  ANY /{id}/delete      
appbundle_admin_filetosync_export  GET|POST ANY  ANY /export.{_format}     
appbundle_admin_filetosync_move_up  GET  ANY  ANY /{id}/move-up      
appbundle_admin_filetosync_move_down GET  ANY  ANY /{id}/move-down      
appbundle_admin_importerror    ANY  ANY  ANY /         
appbundle_admin_importerror_add   GET|POST ANY  ANY /add        
appbundle_admin_importerror_edit  GET|POST ANY  ANY /{id}        
appbundle_admin_importerror_view  GET  ANY  ANY /{id}        
appbundle_admin_importerror_delete  GET|POST ANY  ANY /{id}/delete      
appbundle_admin_importerror_export  GET|POST ANY  ANY /export.{_format}     
appbundle_admin_importerror_move_up  GET  ANY  ANY /{id}/move-up      
appbundle_admin_importerror_move_down GET  ANY  ANY /{id}/move-down 

我怎麼能有應用了這些路線的前綴?

回答

0

kunstmaan bundle在AppBundle/Resources/routing.yml中創建這些前綴,但它們不起作用,因爲路由在註釋中完成,不能在yaml和註釋之間混合使用。

所以我找到了解決方案是從的routing.yml

appbundle_importerror_admin_list: 
    resource: @AppBundle/Controller/ImportErrorAdminListController.php 
    type:  annotation 

appbundle_filetosync_admin_list: 
    resource: @AppBundle/Controller/FileToSyncAdminListController.php 
    type:  annotation 

刪除它們並將它們添加到控制器類:

/** 
* The admin list controller for ImportError 
* 
* @Route("/admin/importerror") 
*/ 

class ImportErrorAdminListController extends AdminListController