Skip to content

Commit

Permalink
TASK: Make NodeSubjectProvider::createMinimalNodeOfType more versatile
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Sep 3, 2023
1 parent b4435db commit 6cccfed
Showing 1 changed file with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -51,7 +51,7 @@
*/
final class NodeSubjectProvider
{
public PropertyConverter $propertyConverter;
private PropertyConverter $propertyConverter;

public function __construct()
{
Expand All @@ -72,32 +72,33 @@ 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'),
ContentStreamId::fromString('cs-id'),
DimensionSpacePoint::fromArray([]),
VisibilityConstraints::withoutRestrictions()
),
NodeAggregateId::create(),
$nodeAggregateId ?? NodeAggregateId::create(),
OriginDimensionSpacePoint::fromArray([]),
NodeAggregateClassification::CLASSIFICATION_REGULAR,
$nodeType->name,
Expand Down

0 comments on commit 6cccfed

Please sign in to comment.