Closed
Description
I think it's a bug related with the feature #19612
I have a route group for an admin section, and I want to prefix the URL and name of each route inside the App\Controller\Admin
namespace.
If I go only for the route prefix it works without any problem
# config/routes.yaml
admin:
prefix: /admin
resource: ../src/Controller/Admin
type: annotation
The router debug gives me the following output:
-------------------------- ---------- -------- ------ -----------------------------------
Name Method Scheme Host Path
-------------------------- ---------- -------- ------ -----------------------------------
_twig_error_test ANY ANY ANY /_error/{code}.{_format}
_wdt ANY ANY ANY /_wdt/{token}
_profiler_home ANY ANY ANY /_profiler/
_profiler_search ANY ANY ANY /_profiler/search
_profiler_search_bar ANY ANY ANY /_profiler/search_bar
_profiler_phpinfo ANY ANY ANY /_profiler/phpinfo
_profiler_search_results ANY ANY ANY /_profiler/{token}/search/results
_profiler_open_file ANY ANY ANY /_profiler/open
_profiler ANY ANY ANY /_profiler/{token}
_profiler_router ANY ANY ANY /_profiler/{token}/router
_profiler_exception ANY ANY ANY /_profiler/{token}/exception
_profiler_exception_css ANY ANY ANY /_profiler/{token}/exception.css
index ANY ANY ANY /admin/
login ANY ANY ANY /admin/login
user_index GET ANY ANY /admin/user
user_new GET|POST ANY ANY /admin/user/new
user_show GET ANY ANY /admin/user/{id}
user_edit GET|POST ANY ANY /admin/user/{id}/edit
user_delete DELETE ANY ANY /admin/user/{id}
admin_logout ANY ANY ANY /admin/logout
-------------------------- ---------- -------- ------ -----------------------------------
The problem comes when I add the name_prefix
route:
# config/routes.yaml
admin:
name_prefix: admin_
prefix: /admin
resource: ../src/Controller/Admin
type: annotation
The router debug gives the following output, and I can verify that the URLs are duplicated:
-------------------------- ---------- -------- ------ -----------------------------------
Name Method Scheme Host Path
-------------------------- ---------- -------- ------ -----------------------------------
index ANY ANY ANY /
login ANY ANY ANY /login
user_index GET ANY ANY /user
user_new GET|POST ANY ANY /user/new
user_show GET ANY ANY /user/{id}
user_edit GET|POST ANY ANY /user/{id}/edit
user_delete DELETE ANY ANY /user/{id}
_twig_error_test ANY ANY ANY /_error/{code}.{_format}
_wdt ANY ANY ANY /_wdt/{token}
_profiler_home ANY ANY ANY /_profiler/
_profiler_search ANY ANY ANY /_profiler/search
_profiler_search_bar ANY ANY ANY /_profiler/search_bar
_profiler_phpinfo ANY ANY ANY /_profiler/phpinfo
_profiler_search_results ANY ANY ANY /_profiler/{token}/search/results
_profiler_open_file ANY ANY ANY /_profiler/open
_profiler ANY ANY ANY /_profiler/{token}
_profiler_router ANY ANY ANY /_profiler/{token}/router
_profiler_exception ANY ANY ANY /_profiler/{token}/exception
_profiler_exception_css ANY ANY ANY /_profiler/{token}/exception.css
admin_index ANY ANY ANY /admin/
admin_login ANY ANY ANY /admin/login
admin_user_index GET ANY ANY /admin/user
admin_user_new GET|POST ANY ANY /admin/user/new
admin_user_show GET ANY ANY /admin/user/{id}
admin_user_edit GET|POST ANY ANY /admin/user/{id}/edit
admin_user_delete DELETE ANY ANY /admin/user/{id}
admin_logout ANY ANY ANY /admin/logout
-------------------------- ---------- -------- ------ -----------------------------------
Originally posted by @devnix in #19612 (comment)