Use fully loaded node entities in routes starting with /node/{node} #12
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.
Passing in the node ID as a string in routes is causing issues with modules that expect routes that are part of
/node/{node}
to have that{node}
be a loaded node entity.This can be demonstrated (and was initially observed) by enabling the Permissions by Term module, which grabs the node out of the route to determine access. Since the
EmbargoesNodeEmbargoesController
gets a string instead of an entity object, the node entity isn't available from the route parameters, and the call to$node->id()
fails.I'm not sure I can dig up any standards describing this as being a hard requirement, but since
/node/{node}
comes from thenode
module itself, it would make sense to align any new sub-routes with how the node module does things. It's also worth mentioning that the{node}
that gets passed into theembargoes.node.embargo
route is already aDrupal\node\Entity\Node
object despite not having been specified, which does reinforce that this behaviour is expected.This PR is to update the
embargoes.node.embargoes
route to use a node entity, to accept that node entity on the other end, and to update theEmbargoesNodeEmbargoesForm
to document what's being passed in.