-
-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4519 from neos/feature/4517-findClosestAncestorNode
FEATURE: Add `ContentSubgraphInterface::findClosestNode()`
- Loading branch information
Showing
7 changed files
with
222 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
98 changes: 98 additions & 0 deletions
98
...ntentRepository.BehavioralTests/Tests/Behavior/Features/NodeTraversal/ClosestNode.feature
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
@contentrepository @adapters=DoctrineDBAL | ||
# TODO implement for Postgres | ||
Feature: Find nodes using the findClosestNode query | ||
|
||
Background: | ||
Given using the following content dimensions: | ||
| Identifier | Values | Generalizations | | ||
| language | mul, de, en, ch | ch->de->mul, en->mul | | ||
And using the following node types: | ||
"""yaml | ||
'Neos.ContentRepository:Root': [] | ||
'Neos.ContentRepository.Testing:AbstractPage': | ||
abstract: true | ||
'Neos.ContentRepository.Testing:SomeMixin': | ||
abstract: true | ||
'Neos.ContentRepository.Testing:Homepage': | ||
superTypes: | ||
'Neos.ContentRepository.Testing:AbstractPage': true | ||
childNodes: | ||
terms: | ||
type: 'Neos.ContentRepository.Testing:Terms' | ||
contact: | ||
type: 'Neos.ContentRepository.Testing:Contact' | ||
'Neos.ContentRepository.Testing:Terms': | ||
superTypes: | ||
'Neos.ContentRepository.Testing:AbstractPage': true | ||
properties: | ||
text: | ||
defaultValue: 'Terms default' | ||
'Neos.ContentRepository.Testing:Contact': | ||
superTypes: | ||
'Neos.ContentRepository.Testing:AbstractPage': true | ||
'Neos.ContentRepository.Testing:SomeMixin': true | ||
properties: | ||
text: | ||
defaultValue: 'Contact default' | ||
'Neos.ContentRepository.Testing:Page': | ||
superTypes: | ||
'Neos.ContentRepository.Testing:AbstractPage': true | ||
'Neos.ContentRepository.Testing:SpecialPage': | ||
superTypes: | ||
'Neos.ContentRepository.Testing:AbstractPage': true | ||
""" | ||
And using identifier "default", I define a content repository | ||
And I am in content repository "default" | ||
And I am user identified by "initiating-user-identifier" | ||
And the command CreateRootWorkspace is executed with payload: | ||
| Key | Value | | ||
| workspaceName | "live" | | ||
| workspaceTitle | "Live" | | ||
| workspaceDescription | "The live workspace" | | ||
| newContentStreamId | "cs-identifier" | | ||
And the graph projection is fully up to date | ||
And I am in content stream "cs-identifier" and dimension space point {"language":"de"} | ||
And the command CreateRootNodeAggregateWithNode is executed with payload: | ||
| Key | Value | | ||
| nodeAggregateId | "lady-eleonode-rootford" | | ||
| nodeTypeName | "Neos.ContentRepository:Root" | | ||
And the graph projection is fully up to date | ||
And the following CreateNodeAggregateWithNode commands are executed: | ||
| nodeAggregateId | nodeName | nodeTypeName | parentNodeAggregateId | initialPropertyValues | tetheredDescendantNodeAggregateIds | | ||
| home | home | Neos.ContentRepository.Testing:Homepage | lady-eleonode-rootford | {} | {"terms": "terms", "contact": "contact"} | | ||
| a | a | Neos.ContentRepository.Testing:Page | home | {} | {} | | ||
| a1 | a1 | Neos.ContentRepository.Testing:Page | a | {} | {} | | ||
| a2 | a2 | Neos.ContentRepository.Testing:Page | a | {} | {} | | ||
| a2a | a2a | Neos.ContentRepository.Testing:SpecialPage | a2 | {} | {} | | ||
| a2a1 | a2a1 | Neos.ContentRepository.Testing:Page | a2a | {} | {} | | ||
| a2a2 | a2a2 | Neos.ContentRepository.Testing:Page | a2a | {} | {} | | ||
| a2a2a | a2a2a | Neos.ContentRepository.Testing:Page | a2a2 | {} | {} | | ||
| a2a2b | a2a2b | Neos.ContentRepository.Testing:Page | a2a2 | {} | {} | | ||
| a2b | a2b | Neos.ContentRepository.Testing:Page | a2 | {} | {} | | ||
| a2b1 | a2b1 | Neos.ContentRepository.Testing:Page | a2b | {} | {} | | ||
| b | b | Neos.ContentRepository.Testing:Page | home | {} | {} | | ||
And the command DisableNodeAggregate is executed with payload: | ||
| Key | Value | | ||
| nodeAggregateId | "a2a2a" | | ||
| nodeVariantSelectionStrategy | "allVariants" | | ||
And the graph projection is fully up to date | ||
And the command DisableNodeAggregate is executed with payload: | ||
| Key | Value | | ||
| nodeAggregateId | "a2b" | | ||
| nodeVariantSelectionStrategy | "allVariants" | | ||
And the graph projection is fully up to date | ||
|
||
Scenario: | ||
# findClosestNode queries without results | ||
# When I execute the findClosestNode query for entry node aggregate id "non-existing" and filter '{"nodeTypeConstraints": "Neos.ContentRepository.Testing:Page"}' I expect no node to be returned | ||
# # a2a2a is disabled | ||
# When I execute the findClosestNode query for entry node aggregate id "a2a2a" and filter '{"nodeTypeConstraints": "Neos.ContentRepository.Testing:Page"}' I expect no node to be returned | ||
# # a2b is disabled | ||
# When I execute the findClosestNode query for entry node aggregate id "a2b1" and filter '{"nodeTypeConstraints": "Neos.ContentRepository.Testing:Page"}' I expect no node to be returned | ||
|
||
# findClosestNode queries with results | ||
When I execute the findClosestNode query for entry node aggregate id "a2a2b" and filter '{"nodeTypeConstraints": "Neos.ContentRepository.Testing:Page"}' I expect the node "a2a2b" to be returned | ||
When I execute the findClosestNode query for entry node aggregate id "a2a2b" and filter '{"nodeTypeConstraints": "Neos.ContentRepository.Testing:SpecialPage"}' I expect the node "a2a" to be returned | ||
When I execute the findClosestNode query for entry node aggregate id "a2a2b" and filter '{"nodeTypeConstraints": "!Neos.ContentRepository.Testing:Page,!Neos.ContentRepository.Testing:SpecialPage"}' I expect the node "home" to be returned | ||
When I execute the findClosestNode query for entry node aggregate id "a2a" and filter '{"nodeTypeConstraints": "Neos.ContentRepository.Testing:SpecialPage"}' I expect the node "a2a" to be returned |
This file contains 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
This file contains 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
42 changes: 42 additions & 0 deletions
42
Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Filter/FindClosestNodeFilter.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Neos\ContentRepository\Core\Projection\ContentGraph\Filter; | ||
|
||
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeTypeConstraints; | ||
|
||
/** | ||
* Immutable filter DTO for {@see ContentSubgraphInterface::findClosestNode()} | ||
* | ||
* Example: | ||
* | ||
* FindClosestAncestorNodeFilter::create(nodeTypeConstraints: 'Some.Included:NodeType,!Some.Excluded:NodeType'); | ||
* | ||
* @api for the factory methods; NOT for the inner state. | ||
*/ | ||
final class FindClosestNodeFilter | ||
{ | ||
/** | ||
* @internal (the properties themselves are readonly; only the write-methods are API. | ||
*/ | ||
private function __construct( | ||
public readonly NodeTypeConstraints $nodeTypeConstraints | ||
) { | ||
} | ||
|
||
/** | ||
* Creates an instance with the specified filter options | ||
* | ||
* Note: The signature of this method might be extended in the future, so it should always be used with named arguments | ||
* @see https://www.php.net/manual/en/functions.arguments.php#functions.named-arguments | ||
*/ | ||
public static function create( | ||
NodeTypeConstraints|string $nodeTypeConstraints | ||
): self { | ||
if (is_string($nodeTypeConstraints)) { | ||
$nodeTypeConstraints = NodeTypeConstraints::fromFilterString($nodeTypeConstraints); | ||
} | ||
return new self($nodeTypeConstraints); | ||
} | ||
} |
This file contains 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