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 usages of $node->subgraphIdentity->contentStreamId in structure adjustments #5081

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 @@ -9,12 +9,13 @@
use Neos\ContentRepository\Core\DimensionSpace\VariantType;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphInterface;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFound;

class DimensionAdjustment
{
public function __construct(
protected ProjectedNodeIterator $projectedNodeIterator,
protected ContentGraphInterface $contentGraph,
protected InterDimensionalVariationGraph $interDimensionalVariationGraph,
protected NodeTypeManager $nodeTypeManager,
) {
Expand All @@ -30,7 +31,7 @@ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): iterable
return [];
}
if ($nodeType->isOfType(NodeTypeName::ROOT_NODE_TYPE_NAME)) {
foreach ($this->projectedNodeIterator->nodeAggregatesOfType($nodeTypeName) as $nodeAggregate) {
foreach ($this->contentGraph->findNodeAggregatesByType($nodeTypeName) as $nodeAggregate) {
if (
!$nodeAggregate->coveredDimensionSpacePoints->equals($this->interDimensionalVariationGraph->getDimensionSpacePoints())
) {
Expand All @@ -42,7 +43,7 @@ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): iterable
}
return [];
}
foreach ($this->projectedNodeIterator->nodeAggregatesOfType($nodeTypeName) as $nodeAggregate) {
foreach ($this->contentGraph->findNodeAggregatesByType($nodeTypeName) as $nodeAggregate) {
foreach ($nodeAggregate->getNodes() as $node) {
foreach (
$nodeAggregate->getCoverageByOccupant(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Neos\ContentRepository\Core\Feature\NodeRemoval\Event\NodeAggregateWasRemoved;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
Expand All @@ -25,7 +26,7 @@ class DisallowedChildNodeAdjustment
use RemoveNodeAggregateTrait;

public function __construct(
private readonly ProjectedNodeIterator $projectedNodeIterator,
private readonly ContentGraphInterface $contentGraph,
private readonly NodeTypeManager $nodeTypeManager,
) {
}
Expand All @@ -40,7 +41,7 @@ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generat
return;
}

foreach ($this->projectedNodeIterator->nodeAggregatesOfType($nodeTypeName) as $nodeAggregate) {
foreach ($this->contentGraph->findNodeAggregatesByType($nodeTypeName) as $nodeAggregate) {
$nodeType = $this->nodeTypeManager->getNodeType($nodeAggregate->nodeTypeName);
if (!$nodeType) {
// unknown child node type, so we skip this test as we won't be able to find out node type constraints
Expand All @@ -51,7 +52,7 @@ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generat
// as it can happen that the constraint is only violated in e.g. "AT", but not in "DE".
// Then, we only want to remove the single edge.
foreach ($nodeAggregate->coveredDimensionSpacePoints as $coveredDimensionSpacePoint) {
$subgraph = $this->projectedNodeIterator->contentGraph->getSubgraph(
$subgraph = $this->contentGraph->getSubgraph(
$coveredDimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
);
Expand Down Expand Up @@ -127,8 +128,8 @@ private function removeNodeInSingleDimensionSpacePoint(
$referenceOrigin = OriginDimensionSpacePoint::fromDimensionSpacePoint($dimensionSpacePoint);
$events = Events::with(
new NodeAggregateWasRemoved(
$this->projectedNodeIterator->contentGraph->getWorkspaceName(),
$this->projectedNodeIterator->contentGraph->getContentStreamId(),
$this->contentGraph->getWorkspaceName(),
$this->contentGraph->getContentStreamId(),
$nodeAggregate->nodeAggregateId,
$nodeAggregate->occupiesDimensionSpacePoint($referenceOrigin)
? new OriginDimensionSpacePointSet([$referenceOrigin])
Expand All @@ -138,7 +139,7 @@ private function removeNodeInSingleDimensionSpacePoint(
);

$streamName = ContentStreamEventStreamName::fromContentStreamId(
$this->projectedNodeIterator->contentGraph->getContentStreamId()
$this->contentGraph->getContentStreamId()
);

return new EventsToPublish(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Neos\ContentRepository\Core\Feature\NodeModification\Event\NodePropertiesWereSet;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate;
use Neos\ContentRepository\Core\SharedModel\Node\PropertyNames;
Expand All @@ -21,7 +22,7 @@
class PropertyAdjustment
{
public function __construct(
private readonly ProjectedNodeIterator $projectedNodeIterator,
private readonly ContentGraphInterface $contentGraph,
private readonly NodeTypeManager $nodeTypeManager
) {
}
Expand All @@ -39,7 +40,7 @@ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generat

$expectedPropertiesFromNodeType = array_filter($nodeType->getProperties(), fn ($value) => $value !== null);

foreach ($this->projectedNodeIterator->nodeAggregatesOfType($nodeTypeName) as $nodeAggregate) {
foreach ($this->contentGraph->findNodeAggregatesByType($nodeTypeName) as $nodeAggregate) {
foreach ($nodeAggregate->getNodes() as $node) {
$propertyKeysInNode = [];

Expand Down Expand Up @@ -115,8 +116,8 @@ private function publishNodePropertiesWereSet(
): EventsToPublish {
$events = Events::with(
new NodePropertiesWereSet(
$node->workspaceName,
$node->subgraphIdentity->contentStreamId,
$this->contentGraph->getWorkspaceName(),
$this->contentGraph->getContentStreamId(),
$node->aggregateId,
$node->originDimensionSpacePoint,
$nodeAggregate->getCoverageByOccupant($node->originDimensionSpacePoint),
Expand All @@ -125,7 +126,7 @@ private function publishNodePropertiesWereSet(
)
);

$streamName = ContentStreamEventStreamName::fromContentStreamId($node->subgraphIdentity->contentStreamId);
$streamName = ContentStreamEventStreamName::fromContentStreamId($this->contentGraph->getContentStreamId());
return new EventsToPublish(
$streamName->getEventStreamName(),
$events,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
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\ContentGraphInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindChildNodesFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
Expand All @@ -30,7 +31,7 @@ class TetheredNodeAdjustments
use TetheredNodeInternals;

public function __construct(
private readonly ProjectedNodeIterator $projectedNodeIterator,
private readonly ContentGraphInterface $contentGraph,
private readonly NodeTypeManager $nodeTypeManager,
private readonly DimensionSpace\InterDimensionalVariationGraph $interDimensionalVariationGraph,
private readonly PropertyConverter $propertyConverter
Expand All @@ -47,7 +48,7 @@ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generat
// In case we cannot find the expected tethered nodes, this fix cannot do anything.
return;
}
foreach ($this->projectedNodeIterator->nodeAggregatesOfType($nodeTypeName) as $nodeAggregate) {
foreach ($this->contentGraph->findNodeAggregatesByType($nodeTypeName) as $nodeAggregate) {
// find missing tethered nodes
$foundMissingOrDisallowedTetheredNodes = false;
$originDimensionSpacePoints = $nodeType->isOfType(NodeTypeName::ROOT_NODE_TYPE_NAME)
Expand All @@ -58,7 +59,7 @@ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generat

foreach ($originDimensionSpacePoints as $originDimensionSpacePoint) {
foreach ($nodeType->tetheredNodeTypeDefinitions as $tetheredNodeTypeDefinition) {
$tetheredNode = $this->projectedNodeIterator->contentGraph->getSubgraph(
$tetheredNode = $this->contentGraph->getSubgraph(
$originDimensionSpacePoint->toDimensionSpacePoint(),
VisibilityConstraints::withoutRestrictions()
)->findNodeByPath(
Expand All @@ -77,15 +78,15 @@ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generat
'The tethered child node "' . $tetheredNodeTypeDefinition->name->value . '" is missing.',
function () use ($nodeAggregate, $originDimensionSpacePoint, $tetheredNodeTypeDefinition) {
$events = $this->createEventsForMissingTetheredNode(
$this->projectedNodeIterator->contentGraph,
$this->contentGraph,
$nodeAggregate,
$originDimensionSpacePoint,
$tetheredNodeTypeDefinition,
null
);

$streamName = ContentStreamEventStreamName::fromContentStreamId(
$this->projectedNodeIterator->contentGraph->getContentStreamId()
$this->contentGraph->getContentStreamId()
);
return new EventsToPublish(
$streamName->getEventStreamName(),
Expand All @@ -102,7 +103,7 @@ function () use ($nodeAggregate, $originDimensionSpacePoint, $tetheredNodeTypeDe
}

// find disallowed tethered nodes
$tetheredNodeAggregates = $this->projectedNodeIterator->contentGraph->findTetheredChildNodeAggregates(
$tetheredNodeAggregates = $this->contentGraph->findTetheredChildNodeAggregates(
$nodeAggregate->nodeAggregateId
);
foreach ($tetheredNodeAggregates as $tetheredNodeAggregate) {
Expand All @@ -115,7 +116,7 @@ function () use ($nodeAggregate, $originDimensionSpacePoint, $tetheredNodeTypeDe
'The tethered child node "'
. $tetheredNodeAggregate->nodeName->value . '" should be removed.',
function () use ($tetheredNodeAggregate) {
return $this->removeNodeAggregate($this->projectedNodeIterator->contentGraph, $tetheredNodeAggregate);
return $this->removeNodeAggregate($this->contentGraph, $tetheredNodeAggregate);
}
);
}
Expand All @@ -124,7 +125,7 @@ function () use ($tetheredNodeAggregate) {
// find wrongly ordered tethered nodes
if ($foundMissingOrDisallowedTetheredNodes === false) {
foreach ($originDimensionSpacePoints as $originDimensionSpacePoint) {
$childNodes = $this->projectedNodeIterator->contentGraph->getSubgraph($originDimensionSpacePoint->toDimensionSpacePoint(), VisibilityConstraints::withoutRestrictions())->findChildNodes($nodeAggregate->nodeAggregateId, FindChildNodesFilter::create());
$childNodes = $this->contentGraph->getSubgraph($originDimensionSpacePoint->toDimensionSpacePoint(), VisibilityConstraints::withoutRestrictions())->findChildNodes($nodeAggregate->nodeAggregateId, FindChildNodesFilter::create());

/** is indexed by node name, and the value is the tethered node itself */
$actualTetheredChildNodes = [];
Expand All @@ -147,8 +148,8 @@ function () use ($tetheredNodeAggregate) {
. ' - actual: '
. implode(', ', array_keys($actualTetheredChildNodes)),
fn () => $this->reorderNodes(
$this->projectedNodeIterator->contentGraph->getWorkspaceName(),
$this->projectedNodeIterator->contentGraph->getContentStreamId(),
$this->contentGraph->getWorkspaceName(),
$this->contentGraph->getContentStreamId(),
$nodeAggregate->getCoverageByOccupant($originDimensionSpacePoint),
$actualTetheredChildNodes,
array_keys($nodeType->tetheredNodeTypeDefinitions->toArray())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphInterface;

class UnknownNodeTypeAdjustment
{
use RemoveNodeAggregateTrait;

public function __construct(
private readonly ProjectedNodeIterator $projectedNodeIterator,
private readonly ContentGraphInterface $contentGraph,
private readonly NodeTypeManager $nodeTypeManager
) {
}
Expand All @@ -33,14 +34,14 @@ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generat
*/
private function removeAllNodesOfType(NodeTypeName $nodeTypeName): \Generator
{
foreach ($this->projectedNodeIterator->nodeAggregatesOfType($nodeTypeName) as $nodeAggregate) {
foreach ($this->contentGraph->findNodeAggregatesByType($nodeTypeName) as $nodeAggregate) {
yield StructureAdjustment::createForNodeAggregate(
$nodeAggregate,
StructureAdjustment::NODE_TYPE_MISSING,
'The node type "' . $nodeTypeName->value
. '" is not found; so the node should be removed (or converted)',
function () use ($nodeAggregate) {
return $this->removeNodeAggregate($this->projectedNodeIterator->contentGraph, $nodeAggregate);
return $this->removeNodeAggregate($this->contentGraph, $nodeAggregate);
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
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\ContentGraphInterface;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepository\StructureAdjustment\Adjustment\DimensionAdjustment;
use Neos\ContentRepository\StructureAdjustment\Adjustment\DisallowedChildNodeAdjustment;
use Neos\ContentRepository\StructureAdjustment\Adjustment\ProjectedNodeIterator;
use Neos\ContentRepository\StructureAdjustment\Adjustment\PropertyAdjustment;
use Neos\ContentRepository\StructureAdjustment\Adjustment\StructureAdjustment;
use Neos\ContentRepository\StructureAdjustment\Adjustment\TetheredNodeAdjustments;
Expand All @@ -29,38 +29,45 @@ class StructureAdjustmentService implements ContentRepositoryServiceInterface
protected PropertyAdjustment $propertyAdjustment;
protected DimensionAdjustment $dimensionAdjustment;

/**
* Content graph bound to the live workspace to iterate over the "real" Nodes; that is, the nodes,
* which have an entry in the Graph Projection's "node" table.
*
* @var ContentGraphInterface
*/
private readonly ContentGraphInterface $liveContentGraph;

public function __construct(
private readonly ContentRepository $contentRepository,
ContentRepository $contentRepository,
private readonly EventPersister $eventPersister,
NodeTypeManager $nodeTypeManager,
InterDimensionalVariationGraph $interDimensionalVariationGraph,
PropertyConverter $propertyConverter,
) {
$projectedNodeIterator = new ProjectedNodeIterator(
$contentRepository->getContentGraph(WorkspaceName::forLive()),
);

$this->liveContentGraph = $contentRepository->getContentGraph(WorkspaceName::forLive());

$this->tetheredNodeAdjustments = new TetheredNodeAdjustments(
$projectedNodeIterator,
$this->liveContentGraph,
$nodeTypeManager,
$interDimensionalVariationGraph,
$propertyConverter
);

$this->unknownNodeTypeAdjustment = new UnknownNodeTypeAdjustment(
$projectedNodeIterator,
$this->liveContentGraph,
$nodeTypeManager
);
$this->disallowedChildNodeAdjustment = new DisallowedChildNodeAdjustment(
$projectedNodeIterator,
$this->liveContentGraph,
$nodeTypeManager
);
$this->propertyAdjustment = new PropertyAdjustment(
$projectedNodeIterator,
$this->liveContentGraph,
$nodeTypeManager
);
$this->dimensionAdjustment = new DimensionAdjustment(
$projectedNodeIterator,
$this->liveContentGraph,
$interDimensionalVariationGraph,
$nodeTypeManager
);
Expand All @@ -71,7 +78,7 @@ public function __construct(
*/
public function findAllAdjustments(): \Generator
{
foreach ($this->contentRepository->getContentGraph(WorkspaceName::forLive())->findUsedNodeTypeNames() as $nodeTypeName) {
foreach ($this->liveContentGraph->findUsedNodeTypeNames() as $nodeTypeName) {
yield from $this->findAdjustmentsForNodeType($nodeTypeName);
}
}
Expand Down
Loading