首页 文章

symfont路由前缀不起作用

提问于
浏览
1

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

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/

但是当我运行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 回答

  • 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
    

相关问题