diff --git a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/DisallowedChildNodeAdjustment.php b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/DisallowedChildNodeAdjustment.php index 0dfa463e7ee..a8b1c362855 100644 --- a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/DisallowedChildNodeAdjustment.php +++ b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/DisallowedChildNodeAdjustment.php @@ -7,23 +7,21 @@ use Neos\ContentRepository\Core\ContentRepository; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet; +use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint; +use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePointSet; use Neos\ContentRepository\Core\EventStore\Events; use Neos\ContentRepository\Core\EventStore\EventsToPublish; use Neos\ContentRepository\Core\Feature\ContentStreamEventStreamName; use Neos\ContentRepository\Core\Feature\NodeRemoval\Event\NodeAggregateWasRemoved; -use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate; -use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint; -use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePointSet; use Neos\ContentRepository\Core\NodeType\NodeTypeManager; use Neos\ContentRepository\Core\NodeType\NodeTypeName; -use Neos\ContentRepository\Core\SharedModel\User\UserId; +use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate; use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints; use Neos\EventStore\Model\EventStream\ExpectedVersion; class DisallowedChildNodeAdjustment { use RemoveNodeAggregateTrait; - use LoadNodeTypeTrait; public function __construct( private readonly ContentRepository $contentRepository, @@ -37,19 +35,17 @@ public function __construct( */ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generator { - $nodeType = $this->loadNodeType($nodeTypeName); - - if ($nodeType === null) { + if (!$this->nodeTypeManager->hasNodeType($nodeTypeName)) { // no adjustments for unknown node types return; } foreach ($this->projectedNodeIterator->nodeAggregatesOfType($nodeTypeName) as $nodeAggregate) { - $nodeType = $this->loadNodeType($nodeAggregate->nodeTypeName); - if ($nodeType === null) { + if (!$this->nodeTypeManager->hasNodeType($nodeAggregate->nodeTypeName)) { // unknown child node type, so we skip this test as we won't be able to find out node type constraints continue; } + $nodeType = $this->nodeTypeManager->getNodeType($nodeAggregate->nodeTypeName); // Here, we iterate over the covered dimension space points of the node aggregate one by one; // as it can happen that the constraint is only violated in e.g. "AT", but not in "DE". @@ -70,8 +66,8 @@ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generat $allowedByParent = true; $parentNodeType = null; if ($parentNode !== null) { - $parentNodeType = $this->loadNodeType($parentNode->nodeTypeName); - if ($parentNodeType !== null) { + if ($this->nodeTypeManager->hasNodeType($parentNode->nodeTypeName)) { + $parentNodeType = $this->nodeTypeManager->getNodeType($parentNode->nodeTypeName); $allowedByParent = $parentNodeType->allowsChildNodeType($nodeType); } } @@ -84,8 +80,8 @@ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generat && $parentNode->classification->isTethered() && !is_null($parentNode->nodeName) ) { - $grandparentNodeType = $this->loadNodeType($grandparentNode->nodeTypeName); - if ($grandparentNodeType !== null) { + if ($this->nodeTypeManager->hasNodeType($grandparentNode->nodeTypeName)) { + $grandparentNodeType = $this->nodeTypeManager->getNodeType($grandparentNode->nodeTypeName); $allowedByGrandparent = $grandparentNodeType->allowsGrandchildNodeType( $parentNode->nodeName->value, $nodeType @@ -153,9 +149,4 @@ private function removeNodeInSingleDimensionSpacePoint( ExpectedVersion::ANY() ); } - - protected function getNodeTypeManager(): NodeTypeManager - { - return $this->nodeTypeManager; - } } diff --git a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/LoadNodeTypeTrait.php b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/LoadNodeTypeTrait.php deleted file mode 100644 index d6f12df889e..00000000000 --- a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/LoadNodeTypeTrait.php +++ /dev/null @@ -1,28 +0,0 @@ -getNodeTypeManager()->getNodeType($nodeTypeName); - } catch (NodeTypeNotFoundException $e) { - // the $nodeTypeName was not found; so we need to remove all nodes of this type. - return null; - } - } -} diff --git a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/PropertyAdjustment.php b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/PropertyAdjustment.php index 2f45a28127b..f84c7a74524 100644 --- a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/PropertyAdjustment.php +++ b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/PropertyAdjustment.php @@ -18,8 +18,6 @@ class PropertyAdjustment { - use LoadNodeTypeTrait; - public function __construct( private readonly ProjectedNodeIterator $projectedNodeIterator, private readonly NodeTypeManager $nodeTypeManager @@ -31,11 +29,12 @@ public function __construct( */ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generator { - $nodeType = $this->loadNodeType($nodeTypeName); - if ($nodeType === null) { + if (!$this->nodeTypeManager->hasNodeType($nodeTypeName)) { // In case we cannot find the expected tethered nodes, this fix cannot do anything. return; } + $nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName); + $expectedPropertiesFromNodeType = array_filter($nodeType->getProperties(), fn ($value) => $value !== null); foreach ($this->projectedNodeIterator->nodeAggregatesOfType($nodeTypeName) as $nodeAggregate) { @@ -132,9 +131,4 @@ private function publishNodePropertiesWereSet( ExpectedVersion::ANY() ); } - - protected function getNodeTypeManager(): NodeTypeManager - { - return $this->nodeTypeManager; - } } diff --git a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/TetheredNodeAdjustments.php b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/TetheredNodeAdjustments.php index 7bff3925f22..aa50bb0324b 100644 --- a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/TetheredNodeAdjustments.php +++ b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/TetheredNodeAdjustments.php @@ -32,7 +32,6 @@ class TetheredNodeAdjustments { use NodeVariationInternals; use RemoveNodeAggregateTrait; - use LoadNodeTypeTrait; use TetheredNodeInternals; public function __construct( @@ -48,11 +47,12 @@ public function __construct( */ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generator { - $nodeType = $this->loadNodeType($nodeTypeName); - if ($nodeType === null) { + if (!$this->nodeTypeManager->hasNodeType($nodeTypeName)) { // In case we cannot find the expected tethered nodes, this fix cannot do anything. return; } + $nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName); + $expectedTetheredNodes = $nodeType->getAutoCreatedChildNodes(); foreach ($this->projectedNodeIterator->nodeAggregatesOfType($nodeTypeName) as $nodeAggregate) { @@ -204,11 +204,6 @@ protected function getInterDimensionalVariationGraph(): DimensionSpace\InterDime return $this->interDimensionalVariationGraph; } - protected function getNodeTypeManager(): NodeTypeManager - { - return $this->nodeTypeManager; - } - /** * array key: name of tethered child node. Value: the Node itself. * @param array $actualTetheredChildNodes diff --git a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/UnknownNodeTypeAdjustment.php b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/UnknownNodeTypeAdjustment.php index 903ae844770..e80657f3602 100644 --- a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/UnknownNodeTypeAdjustment.php +++ b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/UnknownNodeTypeAdjustment.php @@ -10,7 +10,6 @@ class UnknownNodeTypeAdjustment { use RemoveNodeAggregateTrait; - use LoadNodeTypeTrait; public function __construct( private readonly ProjectedNodeIterator $projectedNodeIterator, @@ -23,8 +22,7 @@ public function __construct( */ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generator { - $nodeType = $this->loadNodeType($nodeTypeName); - if ($nodeType === null) { + if (!$this->nodeTypeManager->hasNodeType($nodeTypeName)) { // node type is not existing right now. yield from $this->removeAllNodesOfType($nodeTypeName); } @@ -47,9 +45,4 @@ function () use ($nodeAggregate) { ); } } - - protected function getNodeTypeManager(): NodeTypeManager - { - return $this->nodeTypeManager; - } }