From 893446ca3ca47be2ff4f72abefe49026e932f81f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Mu=CC=88ller?= Date: Sun, 17 Sep 2023 15:55:01 +0200 Subject: [PATCH 1/2] TASK: Adjust to changes in `NodeType` Adjusts to changes to fix task neos/neos-development-collection#4515 --- .../Changes/AbstractStructuralChange.php | 17 +++++++++------- Classes/Fusion/Helper/NodeInfoHelper.php | 20 ++----------------- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/Classes/Domain/Model/Changes/AbstractStructuralChange.php b/Classes/Domain/Model/Changes/AbstractStructuralChange.php index 32cdfde7d7..37a1e48c45 100644 --- a/Classes/Domain/Model/Changes/AbstractStructuralChange.php +++ b/Classes/Domain/Model/Changes/AbstractStructuralChange.php @@ -187,14 +187,17 @@ protected function findChildNodes(Node $node): Nodes protected function isNodeTypeAllowedAsChildNode(Node $node, NodeType $nodeType): bool { $subgraph = $this->contentRepositoryRegistry->subgraphForNode($node); - if (NodeInfoHelper::isAutoCreated($node, $subgraph)) { - $parentNode = $subgraph->findParentNode($node->nodeAggregateId); - return !$parentNode || $parentNode->nodeType->allowsGrandchildNodeType( - $node->nodeName->value, - $nodeType - ); - } else { + $contentRepository = $this->contentRepositoryRegistry->get($node->subgraphIdentity->contentRepositoryId); + $nodeTypeManager = $contentRepository->getNodeTypeManager(); + if (!$node->classification->isTethered()) { return $node->nodeType->allowsChildNodeType($nodeType); } + + $parentNode = $subgraph->findParentNode($node->nodeAggregateId); + return !$parentNode || $nodeTypeManager->allowsGrandchildNodeType( + $parentNode->nodeType, + $node->nodeName, + $nodeType + ); } } diff --git a/Classes/Fusion/Helper/NodeInfoHelper.php b/Classes/Fusion/Helper/NodeInfoHelper.php index 99242bd3de..8bc78add51 100644 --- a/Classes/Fusion/Helper/NodeInfoHelper.php +++ b/Classes/Fusion/Helper/NodeInfoHelper.php @@ -11,6 +11,7 @@ * source code. */ +use Neos\ContentRepository\Core\NodeType\NodeTypeManager; use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\CountAncestorNodesFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindChildNodesFilter; @@ -53,12 +54,6 @@ class NodeInfoHelper implements ProtectedContextAwareInterface */ protected $contentRepositoryRegistry; - /** - * @Flow\Inject - * @var EntityToIdentityConverter - */ - protected $entityToIdentityConverter; - /** * @Flow\Inject * @var PersistenceManagerInterface @@ -236,7 +231,7 @@ protected function getBasicNodeInformation(Node $node): array 'identifier' => $node->nodeAggregateId->jsonSerialize(), 'nodeType' => $node->nodeType->getName(), 'label' => $node->getLabel(), - 'isAutoCreated' => self::isAutoCreated($node, $subgraph), + 'isAutoCreated' => $node->classification->isTethered(), // TODO: depth is expensive to calculate; maybe let's get rid of this? 'depth' => $subgraph->countAncestorNodes( $node->nodeAggregateId, @@ -251,17 +246,6 @@ protected function getBasicNodeInformation(Node $node): array ]; } - public static function isAutoCreated(Node $node, ContentSubgraphInterface $subgraph): bool - { - $parent = $subgraph->findParentNode($node->nodeAggregateId); - if ($parent) { - if (array_key_exists($node->nodeName->value, $parent->nodeType->getAutoCreatedChildNodes())) { - return true; - } - } - return false; - } - /** * Get information for all children of the given parent node. * From 597b2ce1cbb852d02b94a0b5a27da03366dc5821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anke=20H=C3=A4slich?= Date: Mon, 16 Oct 2023 22:28:11 +0200 Subject: [PATCH 2/2] TASK: Fix merge error and remove outdated use statements --- Classes/Domain/Model/Changes/AbstractStructuralChange.php | 8 ++++---- Classes/Fusion/Helper/NodeInfoHelper.php | 8 -------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/Classes/Domain/Model/Changes/AbstractStructuralChange.php b/Classes/Domain/Model/Changes/AbstractStructuralChange.php index da4be77231..127c08005f 100644 --- a/Classes/Domain/Model/Changes/AbstractStructuralChange.php +++ b/Classes/Domain/Model/Changes/AbstractStructuralChange.php @@ -195,9 +195,9 @@ protected function isNodeTypeAllowedAsChildNode(Node $node, NodeType $nodeType): $nodeTypeManager = $this->contentRepositoryRegistry->get($node->subgraphIdentity->contentRepositoryId)->getNodeTypeManager(); return !$parentNode || $nodeTypeManager->isNodeTypeAllowedAsChildToTetheredNode( - $this->getNodeType($parentNode), - $node->nodeName, - $nodeType - ); + $this->getNodeType($parentNode), + $node->nodeName, + $nodeType + ); } } diff --git a/Classes/Fusion/Helper/NodeInfoHelper.php b/Classes/Fusion/Helper/NodeInfoHelper.php index 2c8eb99820..6de4667f91 100644 --- a/Classes/Fusion/Helper/NodeInfoHelper.php +++ b/Classes/Fusion/Helper/NodeInfoHelper.php @@ -11,8 +11,6 @@ * source code. */ -use Neos\ContentRepository\Core\NodeType\NodeTypeManager; -use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\CountAncestorNodesFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindChildNodesFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; @@ -55,12 +53,6 @@ class NodeInfoHelper implements ProtectedContextAwareInterface */ protected $userLocaleService; - /** - * @Flow\Inject - * @var ContentRepositoryRegistry - */ - protected $contentRepositoryRegistry; - /** * @Flow\Inject * @var EntityToIdentityConverter