-
-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
4609 multiple content collection publishing #4616
Conversation
public function completeForNodeOfType(NodeTypeName $nodeTypeName, NodeTypeManager $nodeTypeManager): self | ||
{ | ||
return self::fromArray($this->createNodeAggregateIdsForNodeType($nodeTypeName, $nodeTypeManager)) | ||
->merge($this); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i really like this method or here :D and was thinking as well to put it here.
(originally it was hidden here
Lines 344 to 367 in 10e6373
protected static function populateNodeAggregateIds( | |
NodeType $nodeType, | |
?NodeAggregateIdsByNodePaths $nodeAggregateIds, | |
NodePath $childPath = null | |
): NodeAggregateIdsByNodePaths { | |
if ($nodeAggregateIds === null) { | |
$nodeAggregateIds = NodeAggregateIdsByNodePaths::createEmpty(); | |
} | |
// TODO: handle Multiple levels of autocreated child nodes | |
foreach ($nodeType->getAutoCreatedChildNodes() as $rawChildName => $childNodeType) { | |
$childName = NodeName::fromString($rawChildName); | |
$childPath = $childPath | |
? $childPath->appendPathSegment($childName) | |
: NodePath::fromString($childName->value); | |
if (!$nodeAggregateIds->getNodeAggregateId($childPath)) { | |
$nodeAggregateIds = $nodeAggregateIds->add( | |
$childPath, | |
NodeAggregateId::create() | |
); | |
} | |
} | |
return $nodeAggregateIds; | |
} |
Putting it here exposed will be important for the node templates package as we need it there.
Though i would prefer if there also was a static factory for this so that i dont have to write
NodeAggregateIdsByNodePaths::createEmpty()->completeForNodeOfType(...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes looks pretty practical - and one can easily find this method.
$nodeAggregateIdsByNodePaths = NodeAggregateIdsByNodePaths::createForNodeType($nodeTypeName, $nodeTypeManager);
ideally we should enrich also the doc comments for the both methods about the why one would want to do this. (And maybe also a little about the "what" - that it recursively generates node ids for all declared tethered paths.)
And I am in content stream "cs-identifier" | ||
|
||
Then I expect a node identified by cs-identifier;sir-david-nodenborough;{} to exist in the content graph | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug => Test = ❤️
…escendantNodeAggregateIds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the liberty of adjusting the documentation of CreateNodeAggregateWithNode::withTetheredDescendantNodeAggregateIds
so it reflects the main user-land purpose.
Is this fine with you?
This resolves #4609
Population of NodeAggregateIdsByNodePaths is now done properly, recursively and has its own test cases
Checklist
FEATURE|TASK|BUGFIX
!!!
and have upgrade-instructions