Skip to content
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

!!! TASK: Remove Node::nodeType #5021

Merged
merged 4 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public function build(

$nodeFactory = new NodeFactory(
$projectionFactoryDependencies->contentRepositoryId,
$projectionFactoryDependencies->nodeTypeManager,
$projectionFactoryDependencies->propertyConverter,
$dimensionSpacePointsRepository
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Neos\ContentRepository\Core\Feature\NodeModification\Dto\SerializedPropertyValues;
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Dto\SubtreeTags;
use Neos\ContentRepository\Core\Infrastructure\Property\PropertyConverter;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\Projection\ContentGraph\CoverageByOrigin;
use Neos\ContentRepository\Core\Projection\ContentGraph\DimensionSpacePointsBySubtreeTags;
Expand Down Expand Up @@ -52,7 +51,6 @@ final class NodeFactory
{
public function __construct(
private readonly ContentRepositoryId $contentRepositoryId,
private readonly NodeTypeManager $nodeTypeManager,
mhsdesign marked this conversation as resolved.
Show resolved Hide resolved
private readonly PropertyConverter $propertyConverter,
private readonly DimensionSpacePointsRepository $dimensionSpacePointRepository
) {
Expand All @@ -68,10 +66,6 @@ public function mapNodeRowToNode(
DimensionSpacePoint $dimensionSpacePoint,
VisibilityConstraints $visibilityConstraints
): Node {
$nodeType = $this->nodeTypeManager->hasNodeType($nodeRow['nodetypename'])
? $this->nodeTypeManager->getNodeType($nodeRow['nodetypename'])
: null;

return Node::create(
$this->contentRepositoryId,
$workspaceName,
Expand All @@ -90,7 +84,6 @@ public function mapNodeRowToNode(
isset($nodeRow['originallastmodified']) ? self::parseDateTimeString($nodeRow['originallastmodified']) : null,
),
$visibilityConstraints,
$nodeType,
$contentStreamId
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePointSet;
use Neos\ContentRepository\Core\Feature\NodeModification\Dto\SerializedPropertyValues;
use Neos\ContentRepository\Core\Infrastructure\Property\PropertyConverter;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphIdentity;
use Neos\ContentRepository\Core\Projection\ContentGraph\CoverageByOrigin;
use Neos\ContentRepository\Core\Projection\ContentGraph\DimensionSpacePointsBySubtreeTags;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
Expand All @@ -37,7 +35,6 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\Timestamps;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateClassification;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeName;
Expand All @@ -52,16 +49,12 @@
*/
final class NodeFactory
{
private NodeTypeManager $nodeTypeManager;
mhsdesign marked this conversation as resolved.
Show resolved Hide resolved

private PropertyConverter $propertyConverter;

public function __construct(
private readonly ContentRepositoryId $contentRepositoryId,
NodeTypeManager $nodeTypeManager,
PropertyConverter $propertyConverter
) {
$this->nodeTypeManager = $nodeTypeManager;
$this->propertyConverter = $propertyConverter;
}

Expand All @@ -74,10 +67,6 @@ public function mapNodeRowToNode(
?DimensionSpacePoint $dimensionSpacePoint = null,
?ContentStreamId $contentStreamId = null
): Node {
$nodeType = $this->nodeTypeManager->hasNodeType($nodeRow['nodetypename'])
? $this->nodeTypeManager->getNodeType($nodeRow['nodetypename'])
: null;

return Node::create(
$this->contentRepositoryId,
// todo use actual workspace name
Expand All @@ -102,7 +91,6 @@ public function mapNodeRowToNode(
isset($nodeRow['originallastmodified']) ? self::parseDateTimeString($nodeRow['originallastmodified']) : null,
),
$visibilityConstraints,
$nodeType,
$contentStreamId ?: ContentStreamId::fromString($nodeRow['contentstreamid']),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public function build(

$nodeFactory = new NodeFactory(
$projectionFactoryDependencies->contentRepositoryId,
$projectionFactoryDependencies->nodeTypeManager,
$projectionFactoryDependencies->propertyConverter
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,6 @@
*/
public ?NodeName $nodeName;

/**
* In PHP please fetch the NodeType via the NodeTypeManager or the NodeTypeWithFallbackProvider trait instead.
* {@see $nodeTypeName}
*
* For Fusion please use the EEL Helper:
* ```
* ${Neos.Node.getNodeType(node)}
* ```
* @deprecated will be removed before the final 9.0 release
*/
public ?NodeType $nodeType;

/**
* @param ContentRepositoryId $contentRepositoryId The content-repository this Node belongs to
* @param WorkspaceName $workspaceName The workspace of this Node
Expand All @@ -121,7 +109,6 @@
* @param OriginDimensionSpacePoint $originDimensionSpacePoint The DimensionSpacePoint the node originates in. Usually needed to address a Node in a NodeAggregate in order to update it.
* @param NodeAggregateClassification $classification The classification (regular, root, tethered) of this node
* @param NodeTypeName $nodeTypeName The node's node type name; always set, even if unknown to the NodeTypeManager
* @param NodeType|null $nodeType The node's node type, null if unknown to the NodeTypeManager - @deprecated Don't rely on this too much, as the capabilities of the NodeType here will probably change a lot; Ask the {@see NodeTypeManager} instead
* @param PropertyCollection $properties All properties of this node. References are NOT part of this API; To access references, {@see ContentSubgraphInterface::findReferences()} can be used; To read the serialized properties use {@see PropertyCollection::serialized()}.
* @param NodeName|null $name The optional name of the node, describing its relation to its parent
* @param NodeTags $tags explicit and inherited SubtreeTags of this node
Expand All @@ -141,7 +128,6 @@ private function __construct(
public NodeTags $tags,
public Timestamps $timestamps,
public VisibilityConstraints $visibilityConstraints,
?NodeType $nodeType,
ContentStreamId $contentStreamId
) {
if ($this->classification->isTethered() && $this->name === null) {
Expand All @@ -150,7 +136,6 @@ private function __construct(
// legacy to be removed before Neos9
$this->nodeAggregateId = $this->aggregateId;
$this->nodeName = $this->name;
$this->nodeType = $nodeType;
$this->subgraphIdentity = ContentSubgraphIdentity::create(
$contentRepositoryId,
$contentStreamId,
Expand All @@ -162,9 +147,9 @@ private function __construct(
/**
* @internal The signature of this method can change in the future!
*/
public static function create(ContentRepositoryId $contentRepositoryId, WorkspaceName $workspaceName, DimensionSpacePoint $dimensionSpacePoint, NodeAggregateId $aggregateId, OriginDimensionSpacePoint $originDimensionSpacePoint, NodeAggregateClassification $classification, NodeTypeName $nodeTypeName, PropertyCollection $properties, ?NodeName $nodeName, NodeTags $tags, Timestamps $timestamps, VisibilityConstraints $visibilityConstraints, ?NodeType $nodeType, ContentStreamId $contentStreamId): self
public static function create(ContentRepositoryId $contentRepositoryId, WorkspaceName $workspaceName, DimensionSpacePoint $dimensionSpacePoint, NodeAggregateId $aggregateId, OriginDimensionSpacePoint $originDimensionSpacePoint, NodeAggregateClassification $classification, NodeTypeName $nodeTypeName, PropertyCollection $properties, ?NodeName $nodeName, NodeTags $tags, Timestamps $timestamps, VisibilityConstraints $visibilityConstraints, ContentStreamId $contentStreamId): self
{
return new self($contentRepositoryId, $workspaceName, $dimensionSpacePoint, $aggregateId, $originDimensionSpacePoint, $classification, $nodeTypeName, $properties, $nodeName, $tags, $timestamps, $visibilityConstraints, $nodeType, $contentStreamId);
return new self($contentRepositoryId, $workspaceName, $dimensionSpacePoint, $aggregateId, $originDimensionSpacePoint, $classification, $nodeTypeName, $properties, $nodeName, $tags, $timestamps, $visibilityConstraints, $contentStreamId);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private function removeProperty(NodeAggregate $nodeAggregate, Node $node, string

private function addProperty(NodeAggregate $nodeAggregate, Node $node, string $propertyKey, mixed $defaultValue): EventsToPublish
{
$propertyType = $node->nodeType?->getPropertyType($propertyKey) ?? 'string';
$propertyType = $this->nodeTypeManager->getNodeType($node->nodeTypeName)?->getPropertyType($propertyKey) ?? 'string';
$serializedPropertyValues = SerializedPropertyValues::fromArray([
$propertyKey => SerializedPropertyValue::create($defaultValue, $propertyType)
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use Neos\ContentRepository\Core\Infrastructure\Property\Normalizer\ValueObjectStringDenormalizer;
use Neos\ContentRepository\Core\Infrastructure\Property\PropertyConverter;
use Neos\ContentRepository\Core\NodeType\NodeType;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphIdentity;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeTags;
Expand Down Expand Up @@ -83,23 +84,20 @@ public function usePropertyConverter(PropertyConverter $propertyConverter): void
}

public function createMinimalNodeOfType(
NodeType $nodeType,
NodeTypeName $nodeTypeName,
SerializedPropertyValues $propertyValues = null,
?NodeName $nodeName = null
): Node {
$serializedDefaultPropertyValues = SerializedPropertyValues::defaultFromNodeType($nodeType, $this->propertyConverter);
return Node::create(
ContentRepositoryId::fromString('default'),
WorkspaceName::forLive(),
DimensionSpacePoint::createWithoutDimensions(),
NodeAggregateId::create(),
OriginDimensionSpacePoint::createWithoutDimensions(),
NodeAggregateClassification::CLASSIFICATION_REGULAR,
$nodeType->name,
$nodeTypeName,
new PropertyCollection(
$propertyValues
? $serializedDefaultPropertyValues->merge($propertyValues)
: $serializedDefaultPropertyValues,
$propertyValues ?? SerializedPropertyValues::createEmpty(),
$this->propertyConverter
),
$nodeName,
Expand All @@ -111,7 +109,6 @@ public function createMinimalNodeOfType(
new \DateTimeImmutable()
),
VisibilityConstraints::withoutRestrictions(),
$nodeType,
ContentStreamId::fromString('cs-id'),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ExpressionBasedNodeLabelGenerator implements NodeLabelGeneratorInterface
* @var string
*/
protected $expression = <<<'EEL'
${(node.nodeType.label ? node.nodeType.label : node.nodeTypeName.value) + (node.nodeName ? ' (' + node.nodeName.value + ')' : '')}
${(Neos.Node.getNodeType(node).label || node.nodeTypeName.value) + (node.nodeName ? ' (' + node.nodeName.value + ')' : '')}
EEL;

/**
Expand All @@ -64,7 +64,6 @@ public function getLabel(Node $node): string
if (Utility::parseEelExpression($this->getExpression()) === null) {
return $this->getExpression();
}
$value = Utility::evaluateEelExpression($this->getExpression(), $this->eelEvaluator, ['node' => $node], $this->defaultContextConfiguration);
return (string)$value;
return (string)Utility::evaluateEelExpression($this->getExpression(), $this->eelEvaluator, ['node' => $node], $this->defaultContextConfiguration);
}
}
11 changes: 11 additions & 0 deletions Neos.Neos/Classes/Utility/NodeTypeWithFallbackProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Neos\Neos\Utility;

use Neos\ContentRepository\Core\NodeType\NodeType;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFound;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
Expand All @@ -13,10 +14,20 @@
/**
* Utility trait for retrieving node types for nodes with a built-in fallback mechanism
*
* This is only a temporary drop-in replacement as the automatic fallback handling
* of the NodeTypeManager was removed and Node::getNodeType was also removed.
*
* Its preferred to use the nullable {@see NodeTypeManager::getNodeType()} instead, and for cases where
* the Fallback NodeType is really required use {@see NodeTypeNameFactory::forFallback()}.
*
* @property ContentRepositoryRegistry $contentRepositoryRegistry
* @deprecated to ease migration from Neos 8.3
*/
trait NodeTypeWithFallbackProvider
{
/**
* @deprecated to ease migration from Neos 8.3
*/
protected function getNodeType(Node $node): NodeType
{
$nodeTypeManager = $this->contentRepositoryRegistry->get($node->contentRepositoryId)->getNodeTypeManager();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
prototype(Neos.Neos:RawContent.NodeHeader) < prototype(Neos.Fusion:Component) {

labelParts = ${String.split(node.nodeType.label, ':')}
icon = ${node.nodeType.fullConfiguration.ui.icon}
labelParts = ${String.split(Neos.Node.getNodeType(node).label, ':')}
icon = ${Neos.Node.getNodeType(node).fullConfiguration.ui.icon}
visibilityInformations = Neos.Fusion:DataStructure {
hidden = 'hidden'
[email protected] = ${node.hidden}
Expand All @@ -11,7 +11,7 @@ prototype(Neos.Neos:RawContent.NodeHeader) < prototype(Neos.Fusion:Component) {
renderer = afx`
<header>
<i class={'fas fa-' + props.icon + ' ' + props.icon} @if={props.icon}></i>&nbsp;
{(node.tethered || q(node).is('[instanceof Neos.Neos:Document]')) ? q(node).label() : Translation.translate(props.labelParts[2], node.nodeType.label, [], props.labelParts[1], props.labelParts[0])}
{(node.classification.tethered || q(node).is('[instanceof Neos.Neos:Document]')) ? q(node).label() : Translation.translate(props.labelParts[2], Neos.Node.getNodeType(node).label, [], props.labelParts[1], props.labelParts[0])}
<span @if={props.visibilityInformations}> - {props.visibilityInformations}</span>
</header>
`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
prototype(Neos.Neos:RawContent.NodeProperties) < prototype(Neos.Fusion:Component) {
@private {
items = ${node.nodeType.properties}
items = ${Neos.Node.getNodeType(node).properties}
[email protected] = ${Neos.Array.sortByPropertyPath(value, 'ui.inspector.position')}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Feature: Tests for the "Neos.Neos:ContentCollection" Fusion prototype
include: resource://Neos.Neos/Private/Fusion/Root.fusion

prototype(Neos.Neos:Test.ContentType) < prototype(Neos.Fusion:Value) {
value = ${node.nodeAggregateId.value + ' (' + node.nodeType.name.value + ') '}
value = ${node.nodeAggregateId.value + ' (' + node.nodeTypeName.value + ') '}
}

test = Neos.Neos:ContentCollection {
Expand Down
29 changes: 12 additions & 17 deletions Neos.Neos/Tests/Unit/Fusion/Helper/CachingHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,23 @@
* source code.
*/

use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint;
use Neos\ContentRepository\Core\Feature\NodeModification\Dto\SerializedPropertyValues;
use Neos\ContentRepository\Core\Infrastructure\Property\PropertyConverter;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeTags;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepository\Core\Projection\ContentGraph\PropertyCollection;
use Neos\ContentRepository\Core\Projection\ContentGraph\Timestamps;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateClassification;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepository\Domain\Model\Workspace;
use Neos\ContentRepository\Domain\Service\Context;
use Neos\Flow\Tests\UnitTestCase;
use Neos\Neos\Fusion\Helper\CachingHelper;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphIdentity;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateClassification;
use Neos\ContentRepository\Core\Projection\ContentGraph\Timestamps;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\Projection\ContentGraph\PropertyCollection;
use Neos\ContentRepository\Core\Feature\NodeModification\Dto\SerializedPropertyValues;
use Neos\ContentRepository\Core\Infrastructure\Property\PropertyConverter;
use Symfony\Component\Serializer\Serializer;

/**
Expand Down Expand Up @@ -243,7 +239,6 @@ private function createNode(NodeAggregateId $nodeAggregateId): Node
NodeTags::createEmpty(),
Timestamps::create($now, $now, null, null),
VisibilityConstraints::withoutRestrictions(),
null,
ContentStreamId::fromString("cs-identifier"),
);
}
Expand Down
Loading