symfont路由前缀不起作用

时间:2016-11-10 01:37:10

标签: symfony routing kunstmaan

我已经使用kunstmaan / adminlist-bundle生成了2个管理列表,发现routing.yml中指定的前缀无法识别。

MyBundle / Resource / config / 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/

然而,当我运行bin / console debug时:路由器我得到了

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

如何让这些路线应用前缀?

1 个答案:

答案 0 :(得分:1)

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