Skip to content

Apply AdminRoute options on CRUD controller action routes#7570

Closed
lacatoire wants to merge 3 commits into
EasyCorp:4.xfrom
lacatoire:fix/admin-route-requirements
Closed

Apply AdminRoute options on CRUD controller action routes#7570
lacatoire wants to merge 3 commits into
EasyCorp:4.xfrom
lacatoire:fix/admin-route-requirements

Conversation

@lacatoire
Copy link
Copy Markdown
Contributor

Fixes #7496.

Bug

The #[AdminRoute] attribute applied to a method of a CRUD controller silently ignored every option except path, name, and options['methods']. In particular, requirements, host, schemes, condition, defaults, locale, format, stateless, utf8, and nested options were dropped.

Reproducer from the issue:

#[AdminRoute(
    path: '/preview/{entityId}',
    name: 'preview',
    options: ['requirements' => ['entityId' => Requirement::UUID_V7]]
)]
public function preview(AdminContext $context): Response

Hitting /preview/foo matched the route (requirements were never applied), the controller fetched the entity, and Doctrine failed with a conversion error instead of returning 404.

Fix

AdminRouteGenerator::getCustomActionsConfig() now stores the full $adminRouteInstance->options array, and the CRUD route creation loop applies them to the generated Route through a new shared helper applyAdminRouteOptions().

The two other places that previously implemented the same option-to-route mapping inline (createRouteForAdminAttribute() for standalone admin methods and createRouteFromOldRouteConfig() for dashboard-level routeOptions) have been refactored to use the same helper, which removes a triple duplication.

Tests

  • testAdminRouteAdvancedOptionsOnCrudAction exercises a CRUD controller action with #[AdminRoute] defining requirements, host, schemes, condition, defaults, locale, format, stateless, utf8, and nested options, and asserts each value lands on the generated Route.
  • The pre-existing testAdminDashboardAdvancedRouteOptions still passes (exercises the refactored createRouteFromOldRouteConfig() path).
  • Full tests/Functional/AdminRoute/AdminRouteTest.php suite: 21 tests / 226 assertions, all green locally.

@lacatoire lacatoire force-pushed the fix/admin-route-requirements branch from fca8359 to 80916b1 Compare April 20, 2026 15:30
@lacatoire lacatoire closed this Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant