I am trying to create a handful of Views with a REST Export display. They have paths set behind 'api/.../.../.../%node' where %node will be an ID sent to the request to be upcasted. The basic View has a contextual filter of Content ID (excluded), and then "has any term" from this node.
However, in the contextual filter for "Taxonomy Term ID from URL" with "Load terms from the node page":
if (($node = $this->routeMatch->getParameter('node')) && $node instanceof NodeInterface) {
$entity = $node;
}
This check fails, and thus the nodes terms are not checked.
Do I need a custom parameter for this purpose to tell the system what to look for? I figured as long as the ID is a node, the upcast will still occur but it is not.
Here is what xdebug sees in ViewPageController for route params and arguments:
7611 is the node ID, what part of the process should or usually would upcast this to a Node object?
If I do this in the Views TID argument, of course, then I have a Node:
// Load default argument from node.
if (!empty($this->options['node'])) {
// Just check, if a node could be detected.
if (($node = $this->routeMatch->getParameter('node')) && $node instanceof NodeInterface) {
$entity = $node;
}
if (($node = $this->routeMatch->getParameter('node')) && !empty($node) && !($node instanceof NodeInterface)) {
$entity = \Drupal::entityTypeManager()->getStorage('node')->load($node);
}
}
Edit: possibly related: https://www.drupal.org/project/drupal/issues/2528166