symfonyrouteskunstmaan

symfont route prefix not working


I've generated 2 admin lists with kunstmaan/adminlist-bundle and found that the prefix specified in routing.yml is not recognized.

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/

However when I run bin/console debug:router I get

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

How can I have these routes have their prefixes applied?


Solution

  • kunstmaan bundle creates these prefixes in AppBundle/Resources/routing.yml, but they don't work, because routing is done in annotations and can't be mixed between yaml and annotation.

    So the solution I found is to remove them from routing.yml

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

    and to add them to the controller classes:

    /**
     * The admin list controller for ImportError
     *
     * @Route("/admin/importerror")
     */
    
    class ImportErrorAdminListController extends AdminListController