From 6cccfed5612a26ceaef4607d5dd4c7072b53a404 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Sun, 3 Sep 2023 20:52:47 +0200 Subject: [PATCH] TASK: Make NodeSubjectProvider::createMinimalNodeOfType more versatile #4317 --- .../Classes/Unit/NodeSubjectProvider.php | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Neos.ContentRepository.TestSuite/Classes/Unit/NodeSubjectProvider.php b/Neos.ContentRepository.TestSuite/Classes/Unit/NodeSubjectProvider.php index ecf9d8f3160..3b670b3e1c2 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Unit/NodeSubjectProvider.php +++ b/Neos.ContentRepository.TestSuite/Classes/Unit/NodeSubjectProvider.php @@ -17,7 +17,7 @@ use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint; use Neos\ContentRepository\Core\Factory\ContentRepositoryId; -use Neos\ContentRepository\Core\Feature\NodeModification\Dto\SerializedPropertyValue; +use Neos\ContentRepository\Core\Feature\NodeModification\Dto\PropertyValuesToWrite; use Neos\ContentRepository\Core\Feature\NodeModification\Dto\SerializedPropertyValues; use Neos\ContentRepository\Core\Infrastructure\Property\Normalizer\ArrayNormalizer; use Neos\ContentRepository\Core\Infrastructure\Property\Normalizer\CollectionTypeDenormalizer; @@ -51,7 +51,7 @@ */ final class NodeSubjectProvider { - public PropertyConverter $propertyConverter; + private PropertyConverter $propertyConverter; public function __construct() { @@ -72,24 +72,25 @@ public function __construct() ); } - public function usePropertyConverter(PropertyConverter $propertyConverter): void + public function setPropertyConverter(PropertyConverter $propertyConverter): void { $this->propertyConverter = $propertyConverter; } public function createMinimalNodeOfType( NodeType $nodeType, - SerializedPropertyValues $propertyValues = null, - ?NodeName $nodeName = null + SerializedPropertyValues|PropertyValuesToWrite|null $propertyValues = null, + ?NodeName $nodeName = null, + ?NodeAggregateId $nodeAggregateId = null ): Node { - $defaultPropertyValues = []; - foreach ($nodeType->getDefaultValuesForProperties() as $propertyName => $propertyValue) { - $defaultPropertyValues[$propertyName] = new SerializedPropertyValue( - $propertyValue, - $nodeType->getPropertyType($propertyName) + if ($propertyValues instanceof PropertyValuesToWrite) { + $propertyValues = $this->propertyConverter->serializePropertyValues( + $propertyValues, + $nodeType ); } - $serializedDefaultPropertyValues = SerializedPropertyValues::fromArray($defaultPropertyValues); + + $serializedDefaultPropertyValues = SerializedPropertyValues::defaultFromNodeType($nodeType); return new Node( ContentSubgraphIdentity::create( ContentRepositoryId::fromString('default'), @@ -97,7 +98,7 @@ public function createMinimalNodeOfType( DimensionSpacePoint::fromArray([]), VisibilityConstraints::withoutRestrictions() ), - NodeAggregateId::create(), + $nodeAggregateId ?? NodeAggregateId::create(), OriginDimensionSpacePoint::fromArray([]), NodeAggregateClassification::CLASSIFICATION_REGULAR, $nodeType->name,