Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/9.0' into task/followup-4520-nod…
Browse files Browse the repository at this point in the history
…eTypeManger
  • Loading branch information
mhsdesign committed May 17, 2024
2 parents ab41496 + a857349 commit f4fe493
Show file tree
Hide file tree
Showing 36 changed files with 675 additions and 637 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
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 @@ -36,8 +35,7 @@
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\Exception\NodeTypeNotFoundException;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFound;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateClassification;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeName;
Expand Down Expand Up @@ -159,7 +157,7 @@ public function mapReferenceRowsToReferences(

/**
* @param array<int,array<string,string>> $nodeRows
* @throws NodeTypeNotFoundException
* @throws NodeTypeNotFound
*/
public function mapNodeRowsToNodeAggregate(
array $nodeRows,
Expand All @@ -176,7 +174,7 @@ public function mapNodeRowsToNodeAggregate(
$rawNodeName = '';
$rawNodeAggregateClassification = '';
$occupiedDimensionSpacePoints = [];
$nodesByOccupiedDimensionSpacePoints = [];
$nodesByOccupiedDimensionSpacePoint = [];
$coveredDimensionSpacePoints = [];
$nodesByCoveredDimensionSpacePoints = [];
$coverageByOccupants = [];
Expand All @@ -186,9 +184,9 @@ public function mapNodeRowsToNodeAggregate(
foreach ($nodeRows as $nodeRow) {
// A node can occupy exactly one DSP and cover multiple ones...
$occupiedDimensionSpacePoint = $this->dimensionSpacePointRepository->getOriginDimensionSpacePointByHash($nodeRow['origindimensionspacepointhash']);
if (!isset($nodesByOccupiedDimensionSpacePoints[$occupiedDimensionSpacePoint->hash])) {
if (!isset($nodesByOccupiedDimensionSpacePoint[$occupiedDimensionSpacePoint->hash])) {
// ... so we handle occupation exactly once ...
$nodesByOccupiedDimensionSpacePoints[$occupiedDimensionSpacePoint->hash] = $this->mapNodeRowToNode(
$nodesByOccupiedDimensionSpacePoint[$occupiedDimensionSpacePoint->hash] = $this->mapNodeRowToNode(
$nodeRow,
$workspaceName,
$contentStreamId,
Expand All @@ -211,7 +209,7 @@ public function mapNodeRowsToNodeAggregate(
= $coveredDimensionSpacePoint;
$occupationByCovering[$coveredDimensionSpacePoint->hash] = $occupiedDimensionSpacePoint;
$nodesByCoveredDimensionSpacePoints[$coveredDimensionSpacePoint->hash]
= $nodesByOccupiedDimensionSpacePoints[$occupiedDimensionSpacePoint->hash];
= $nodesByOccupiedDimensionSpacePoint[$occupiedDimensionSpacePoint->hash];
// ... as we do for explicit subtree tags
foreach (self::extractNodeTagsFromJson($nodeRow['subtreetags'])->withoutInherited() as $explicitTag) {
$dimensionSpacePointsBySubtreeTags = $dimensionSpacePointsBySubtreeTags->withSubtreeTagAndDimensionSpacePoint($explicitTag, $coveredDimensionSpacePoint);
Expand All @@ -220,8 +218,9 @@ public function mapNodeRowsToNodeAggregate(
ksort($occupiedDimensionSpacePoints);
ksort($coveredDimensionSpacePoints);

/** @var Node $primaryNode a nodeAggregate only exists if it at least contains one node. */
$primaryNode = current($nodesByOccupiedDimensionSpacePoints);
// a nodeAggregate only exists if it at least contains one node
assert($nodesByOccupiedDimensionSpacePoint !== []);
$primaryNode = current($nodesByOccupiedDimensionSpacePoint);

return new NodeAggregate(
$primaryNode->subgraphIdentity->contentStreamId,
Expand All @@ -230,7 +229,7 @@ public function mapNodeRowsToNodeAggregate(
NodeTypeName::fromString($rawNodeTypeName),
$rawNodeName ? NodeName::fromString($rawNodeName) : null,
new OriginDimensionSpacePointSet($occupiedDimensionSpacePoints),
$nodesByOccupiedDimensionSpacePoints,
$nodesByOccupiedDimensionSpacePoint,
CoverageByOrigin::fromArray($coverageByOccupants),
new DimensionSpacePointSet($coveredDimensionSpacePoints),
$nodesByCoveredDimensionSpacePoints,
Expand All @@ -242,7 +241,7 @@ public function mapNodeRowsToNodeAggregate(
/**
* @param iterable<int,array<string,string>> $nodeRows
* @return iterable<int,NodeAggregate>
* @throws NodeTypeNotFoundException
* @throws NodeTypeNotFound
*/
public function mapNodeRowsToNodeAggregates(
iterable $nodeRows,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ public function getWeightedDimensionSpacePointByHash(string $hash): ?WeightedDim
/**
* Returns the root generalizations indexed by hash
*
* @return array<string,DimensionSpacePoint>
* Even in a zero-dimensional content repository the array will have at least one entry
* of an empty dimension space point {@see DimensionSpacePoint::createWithoutDimensions()}
*
* @return non-empty-array<string,DimensionSpacePoint>
*/
public function getRootGeneralizations(): array
{
Expand All @@ -127,7 +130,13 @@ public function getRootGeneralizations(): array
$rootGeneralizations[$dimensionSpacePointHash] = $weightedDimensionSpacePoint->dimensionSpacePoint;
}
}

if (empty($rootGeneralizations)) {
// safeguard, should not happen here:
throw new \RuntimeException(
'The dimension space is empty, please check your configuration.',
1710613747
);
}
return $rootGeneralizations;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeIsNotOfTypeRoot;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeIsOfTypeRoot;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFound;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFoundException;
use Neos\ContentRepository\Core\SharedModel\Exception\PropertyCannotBeSet;
use Neos\ContentRepository\Core\SharedModel\Exception\ReferenceCannotBeSet;
use Neos\ContentRepository\Core\SharedModel\Exception\RootNodeAggregateDoesNotExist;
Expand Down Expand Up @@ -312,7 +311,7 @@ protected function requireConstraintsImposedByAncestorsAreMet(
}

/**
* @throws NodeTypeNotFoundException
* @throws NodeTypeNotFound
* @throws NodeConstraintException
*/
protected function requireNodeTypeConstraintsImposedByParentToBeMet(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodePath;
use Neos\ContentRepository\Core\SharedModel\Exception\ContentStreamDoesNotExistYet;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFoundException;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFound;
use Neos\ContentRepository\Core\SharedModel\Exception\PropertyCannotBeSet;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateClassification;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
Expand Down Expand Up @@ -122,7 +122,7 @@ private function validateProperties(?PropertyValuesToWrite $propertyValues, Node

/**
* @throws ContentStreamDoesNotExistYet
* @throws NodeTypeNotFoundException
* @throws NodeTypeNotFound
*/
private function handleCreateNodeAggregateWithNodeAndSerializedProperties(
CreateNodeAggregateWithNodeAndSerializedProperties $command,
Expand Down Expand Up @@ -252,7 +252,7 @@ private function createRegularWithNode(

/**
* @throws ContentStreamDoesNotExistYet
* @throws NodeTypeNotFoundException
* @throws NodeTypeNotFound
*/
private function handleTetheredChildNodes(
CreateNodeAggregateWithNodeAndSerializedProperties $command,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
use Neos\ContentRepository\Core\SharedModel\Exception\NodeAggregatesTypeIsAmbiguous;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeConstraintException;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFound;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFoundException;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeName;

Expand Down Expand Up @@ -97,7 +96,7 @@ abstract protected function createEventsForMissingTetheredNode(
/**
* @throws NodeTypeNotFound
* @throws NodeConstraintException
* @throws NodeTypeNotFoundException
* @throws NodeTypeNotFound
* @throws NodeAggregatesTypeIsAmbiguous
* @throws \Exception
*/
Expand Down Expand Up @@ -221,7 +220,7 @@ private function handleChangeNodeAggregateType(
/**
* NOTE: when changing this method, {@see NodeTypeChange::deleteDisallowedNodesWhenChangingNodeType}
* needs to be modified as well (as they are structurally the same)
* @throws NodeConstraintException|NodeTypeNotFoundException
* @throws NodeConstraintException|NodeTypeNotFound
*/
private function requireConstraintsImposedByHappyPathStrategyAreMet(
ContentGraphInterface $contentGraph,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
use Neos\ContentRepository\Core\SharedModel\Exception\NodeAggregatesTypeIsAmbiguous;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeIsNotOfTypeRoot;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFound;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFoundException;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateClassification;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeName;
Expand Down Expand Up @@ -180,7 +179,7 @@ private function handleUpdateRootNodeAggregateDimensions(

/**
* @throws ContentStreamDoesNotExistYet
* @throws NodeTypeNotFoundException
* @throws NodeTypeNotFound
*/
private function handleTetheredRootChildNodes(
ContentStreamId $contentStreamId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ function () use ($commandHandlingDependencies, $remainingCommands) {
* @throws WorkspaceDoesNotExist
* @throws WorkspaceHasNoBaseWorkspaceName
* @throws \Neos\ContentRepository\Core\SharedModel\Exception\NodeConstraintException
* @throws \Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFoundException
* @throws \Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFound
* @throws \Symfony\Component\Serializer\Exception\ExceptionInterface
*/
private function handleDiscardIndividualNodesFromWorkspace(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use Neos\ContentRepository\Core\SharedModel\Exception\NodeConfigurationException;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeIsFinalException;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFoundException;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFound;
use Neos\ContentRepository\Core\SharedModel\Node\NodeName;
use Neos\Utility\Arrays;
use Neos\Utility\Exception\PropertyNotAccessibleException;
Expand Down Expand Up @@ -107,7 +107,7 @@ public function getSubNodeTypes(string|NodeTypeName $superTypeName, bool $includ
/**
* Returns the specified node type (which could be abstract)
*
* @throws NodeTypeNotFoundException
* @throws NodeTypeNotFound
*/
public function getNodeType(string|NodeTypeName $nodeTypeName): ?NodeType
{
Expand Down Expand Up @@ -242,7 +242,7 @@ public function isNodeTypeAllowedAsChildToTetheredNode(NodeTypeName $parentNodeT
* @param array<string,mixed> $completeNodeTypeConfiguration the full node type configuration for all node types
* @throws NodeConfigurationException
* @throws NodeTypeIsFinalException
* @throws NodeTypeNotFoundException
* @throws NodeTypeNotFound
*/
private function loadNodeType(string $nodeTypeName, array &$completeNodeTypeConfiguration): NodeType
{
Expand All @@ -251,7 +251,7 @@ private function loadNodeType(string $nodeTypeName, array &$completeNodeTypeConf
}

if (!isset($completeNodeTypeConfiguration[$nodeTypeName])) {
throw new NodeTypeNotFoundException('Node type "' . $nodeTypeName . '" does not exist', 1316451800);
throw new NodeTypeNotFound('Node type "' . $nodeTypeName . '" does not exist', 1316451800);
}

$nodeTypeConfiguration = $completeNodeTypeConfiguration[$nodeTypeName];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,22 @@
* This interface is called *Readable* because it exposes read operations on the set of nodes inside
* a single NodeAggregate; often used for constraint checks (in command handlers).
*
* @api
* @api except its constructor.
*/
final readonly class NodeAggregate
{
/**
* @internal
* @param ContentStreamId $contentStreamId ID of the content stream of this node aggregate
* @param NodeAggregateId $nodeAggregateId ID of this node aggregate
* @param NodeAggregateClassification $classification whether this aggregate represents a root, regular or tethered node
* @param NodeTypeName $nodeTypeName name of the node type of this aggregate
* @param NodeName|null $nodeName optional name of this aggregate
* @param OriginDimensionSpacePointSet $occupiedDimensionSpacePoints dimension space points this aggregate occupies
* @param array<string,Node> $nodesByOccupiedDimensionSpacePoint
* @param non-empty-array<string,Node> $nodesByOccupiedDimensionSpacePoint At least one node will be occupied.
* @param CoverageByOrigin $coverageByOccupant
* @param DimensionSpacePointSet $coveredDimensionSpacePoints
* @param array<string,Node> $nodesByCoveredDimensionSpacePoint
* @param DimensionSpacePointSet $coveredDimensionSpacePoints This node aggregate will cover at least one dimension space.
* @param non-empty-array<string,Node> $nodesByCoveredDimensionSpacePoint At least one node will be covered.
* @param OriginByCoverage $occupationByCovered
* @param DimensionSpacePointsBySubtreeTags $dimensionSpacePointsBySubtreeTags dimension space points for every subtree tag this aggregate is *explicitly* tagged with (excluding inherited tags)
*/
Expand All @@ -87,16 +88,6 @@ public function occupiesDimensionSpacePoint(OriginDimensionSpacePoint $originDim
return $this->occupiedDimensionSpacePoints->contains($originDimensionSpacePoint);
}

/**
* Returns the nodes belonging to this aggregate, i.e. the "real materialized" node rows.
*
* @return iterable<int,Node>
*/
public function getNodes(): iterable
{
return array_values($this->nodesByOccupiedDimensionSpacePoint);
}

public function getNodeByOccupiedDimensionSpacePoint(
OriginDimensionSpacePoint $occupiedDimensionSpacePoint
): Node {
Expand Down Expand Up @@ -164,4 +155,15 @@ public function getDimensionSpacePointsTaggedWith(SubtreeTag $subtreeTag): Dimen
{
return $this->dimensionSpacePointsBySubtreeTags->forSubtreeTag($subtreeTag);
}

/**
* Returns the nodes belonging to this aggregate, i.e. the "real materialized" node rows.
*
* @internal Using this method to access all occupied nodes or possibly extract a single arbitrary node is not intended for use outside the core.
* @return iterable<int,Node>
*/
public function getNodes(): iterable
{
return array_values($this->nodesByOccupiedDimensionSpacePoint);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeConfigurationException;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeIsFinalException;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFoundException;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFound;
use PHPUnit\Framework\TestCase;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Neos\ContentRepository\Core\DimensionSpace\VariantType;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFoundException;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFound;

class DimensionAdjustment
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use Behat\Gherkin\Node\TableNode;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFoundException;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFound;
use Neos\ContentRepository\StructureAdjustment\Adjustment\StructureAdjustment;
use Neos\ContentRepository\StructureAdjustment\StructureAdjustmentService;
use Neos\ContentRepository\StructureAdjustment\StructureAdjustmentServiceFactory;
Expand All @@ -31,7 +31,7 @@ trait StructureAdjustmentsTrait

/**
* @When /^I adjust the node structure for node type "([^"]*)"$/
* @throws NodeTypeNotFoundException
* @throws NodeTypeNotFound
*/
public function iAdjustTheNodeStructureForNodeType(string $nodeTypeName): void
{
Expand All @@ -45,7 +45,7 @@ public function iAdjustTheNodeStructureForNodeType(string $nodeTypeName): void

/**
* @Then I expect no needed structure adjustments for type :nodeTypeName
* @throws NodeTypeNotFoundException
* @throws NodeTypeNotFound
*/
public function iExpectNoStructureAdjustmentsForType(string $nodeTypeName): void
{
Expand All @@ -58,7 +58,7 @@ public function iExpectNoStructureAdjustmentsForType(string $nodeTypeName): void

/**
* @Then /^I expect the following structure adjustments for type "([^"]*)":$/
* @throws NodeTypeNotFoundException
* @throws NodeTypeNotFound
*/
public function iExpectTheFollowingStructureAdjustmentsForType(string $nodeTypeName, TableNode $expectedAdjustments): void
{
Expand Down
Loading

0 comments on commit f4fe493

Please sign in to comment.