Skip to content

Commit

Permalink
BUGFIX: Consider entry node in nodes endpoint for filtering (used in …
Browse files Browse the repository at this point in the history
…reference editor)
  • Loading branch information
mhsdesign committed Aug 4, 2024
1 parent ef93f94 commit 4715f33
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ public function merge(self $other): self
return self::fromArray($nodes);
}

public function append(Node $node): self
{
return new self([...$this->nodes, $node]);
}

public function reverse(): self
{
return new self(array_reverse($this->nodes));
Expand Down
24 changes: 19 additions & 5 deletions Neos.Neos/Classes/Controller/Service/NodesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindChildNodesFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindDescendantNodesFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\ExpandedNodeTypeCriteria;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\NodeTypeCriteria;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\SearchTerm\SearchTermMatcher;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate;
use Neos\ContentRepository\Core\Projection\ContentGraph\Nodes;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
Expand Down Expand Up @@ -148,16 +151,27 @@ public function indexAction(
$entryNode = $subgraph->findNodeByAbsolutePath($nodePath);
}

$nodes = !is_null($entryNode) ? $subgraph->findDescendantNodes(
$entryNode->aggregateId,
FindDescendantNodesFilter::create(
$nodes = Nodes::createEmpty();
if (!is_null($entryNode)) {
$filter = FindDescendantNodesFilter::create(
nodeTypes: NodeTypeCriteria::create(
NodeTypeNames::fromStringArray($nodeTypes),
NodeTypeNames::createEmpty()
),
searchTerm: $searchTerm,
)
) : [];
);
if (
SearchTermMatcher::matchesNode($entryNode, $filter->searchTerm)

Check failure on line 164 in Neos.Neos/Classes/Controller/Service/NodesController.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 Test linting-unit-functionaltests-mysql (deps: highest)

Parameter #2 $searchTerm of static method Neos\ContentRepository\Core\Projection\ContentGraph\Filter\SearchTerm\SearchTermMatcher::matchesNode() expects Neos\ContentRepository\Core\Projection\ContentGraph\Filter\SearchTerm\SearchTerm, Neos\ContentRepository\Core\Projection\ContentGraph\Filter\SearchTerm\SearchTerm|null given.

Check failure on line 164 in Neos.Neos/Classes/Controller/Service/NodesController.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 Test linting-unit-functionaltests-mysql (deps: highest)

Parameter #2 $searchTerm of static method Neos\ContentRepository\Core\Projection\ContentGraph\Filter\SearchTerm\SearchTermMatcher::matchesNode() expects Neos\ContentRepository\Core\Projection\ContentGraph\Filter\SearchTerm\SearchTerm, Neos\ContentRepository\Core\Projection\ContentGraph\Filter\SearchTerm\SearchTerm|null given.
&& ExpandedNodeTypeCriteria::create($filter->nodeTypes, $contentRepository->getNodeTypeManager())

Check failure on line 165 in Neos.Neos/Classes/Controller/Service/NodesController.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 Test linting-unit-functionaltests-mysql (deps: highest)

Parameter #1 $nodeTypeCriteria of static method Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\ExpandedNodeTypeCriteria::create() expects Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\NodeTypeCriteria, Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\NodeTypeCriteria|null given.

Check failure on line 165 in Neos.Neos/Classes/Controller/Service/NodesController.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 Test linting-unit-functionaltests-mysql (deps: highest)

The internal method "Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\ExpandedNodeTypeCriteria::matches" is called.

Check failure on line 165 in Neos.Neos/Classes/Controller/Service/NodesController.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 Test linting-unit-functionaltests-mysql (deps: highest)

Parameter #1 $nodeTypeCriteria of static method Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\ExpandedNodeTypeCriteria::create() expects Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\NodeTypeCriteria, Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\NodeTypeCriteria|null given.

Check failure on line 165 in Neos.Neos/Classes/Controller/Service/NodesController.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 Test linting-unit-functionaltests-mysql (deps: highest)

The internal method "Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\ExpandedNodeTypeCriteria::matches" is called.
->matches($entryNode->nodeTypeName)
) {
// include the starting node if it matches
$nodes = $nodes->append($entryNode);
}
$nodes = $nodes->merge(
$subgraph->findDescendantNodes($entryNode->aggregateId, $filter)
);
}
} else {
if (!empty($searchTerm)) {
throw new \RuntimeException('Combination of $nodeIdentifiers and $searchTerm not supported');
Expand Down

0 comments on commit 4715f33

Please sign in to comment.