Apply AdminRoute options on CRUD controller action routes#7570
Closed
lacatoire wants to merge 3 commits into
Closed
Apply AdminRoute options on CRUD controller action routes#7570lacatoire wants to merge 3 commits into
lacatoire wants to merge 3 commits into
Conversation
fca8359 to
80916b1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7496.
Bug
The
#[AdminRoute]attribute applied to a method of a CRUD controller silently ignored every option exceptpath,name, andoptions['methods']. In particular,requirements,host,schemes,condition,defaults,locale,format,stateless,utf8, and nestedoptionswere dropped.Reproducer from the issue:
#[AdminRoute( path: '/preview/{entityId}', name: 'preview', options: ['requirements' => ['entityId' => Requirement::UUID_V7]] )] public function preview(AdminContext $context): ResponseHitting
/preview/foomatched 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->optionsarray, and the CRUD route creation loop applies them to the generatedRoutethrough a new shared helperapplyAdminRouteOptions().The two other places that previously implemented the same option-to-route mapping inline (
createRouteForAdminAttribute()for standalone admin methods andcreateRouteFromOldRouteConfig()for dashboard-levelrouteOptions) have been refactored to use the same helper, which removes a triple duplication.Tests
testAdminRouteAdvancedOptionsOnCrudActionexercises a CRUD controller action with#[AdminRoute]definingrequirements,host,schemes,condition,defaults,locale,format,stateless,utf8, and nestedoptions, and asserts each value lands on the generatedRoute.testAdminDashboardAdvancedRouteOptionsstill passes (exercises the refactoredcreateRouteFromOldRouteConfig()path).tests/Functional/AdminRoute/AdminRouteTest.phpsuite: 21 tests / 226 assertions, all green locally.