- First commit to issue fork.
- last update
over 1 year ago 29,359 pass, 2 fail - @slydevil opened merge request.
- last update
over 1 year ago 29,359 pass, 2 fail
While working with a custom entity I noticed that content moderation EntityTypeInfo::bundleFormRedirect() makes an assumption regarding the parameters to pass to an entity's latest-version route. The assumption made is that the only parameter is the ID of the entity. In my use case, I have a custom entity (registrant) which directly relates to another entity (event) and the route structure is as follows:
/events/{event}/registrations/{registrant}
For example:
/events/123/registrations/10
The latest-version route automatically created by content moderation creates a route (entity.registrant.latest-version) which is based upon the canonical route for that entity, and adds '/latest' to the end, which forms a path as follows:
/events/{event}/registrations/{registrant}/latest
The problem is that EntityTypeInfo::bundleFormRedirect() assumes that all entity latest-version paths will be similar to those of nodes, such as:
/node/123/latest
So when it runs the following
$form_state->setRedirect("entity.$entity_type_id.latest_version", [$entity_type_id => $entity->id()]);
For a node this would work fine, but my paths require another route parameter.
* Create a custom entity with a multi-variable canonical route URL containing more than one parameter.
* Enable content moderation and workflow for that entity
* Create a non-published (draft by default) revision of that entity
* You will see the following error:
Symfony\Component\Routing\Exception\MissingMandatoryParametersException: Some mandatory parameters are missing ("registrant") to generate a URL for route "entity.registrant.latest_version".
Given that bundleFormRedirect() has access to the entity to generate the redirect, it could use the entities 'toUrl()' method to generate the latest-version Url object and switch to using setRedirectUrl() instead of setRedirect() on the form state.
Write tests?
None
None?
None
Fix latest-version form state redirect URL for entities with hierarchical route paths
Needs work
10.1 β¨
The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.