Skip to content

Commit

Permalink
TASK: Guard NodeDataToEventsProcessor::setSitesNodeType
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Sep 27, 2023
1 parent deae06c commit 724df3c
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function __construct(
private readonly Filesystem $files,
private readonly iterable $nodeDataRows,
) {
$this->sitesNodeTypeName = NodeTypeName::fromString('Neos.Neos:Sites');
$this->sitesNodeTypeName = NodeTypeName::fromString(NodeTypeNameFactory::NAME_SITES);
$this->contentStreamId = ContentStreamId::create();
$this->visitedNodes = new VisitedNodeAggregates();
}
Expand All @@ -98,6 +98,13 @@ public function setContentStreamId(ContentStreamId $contentStreamId): void

public function setSitesNodeType(NodeTypeName $nodeTypeName): void
{
$nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName);
if (!$nodeType->isOfType(NodeTypeNameFactory::NAME_SITES)) {
throw new \InvalidArgumentException(
sprintf('Sites NodeType "%s" must be of type "%s".', $nodeTypeName->value, NodeTypeNameFactory::NAME_SITES),
1695802415
);
}
$this->sitesNodeTypeName = $nodeTypeName;
}

Expand Down Expand Up @@ -245,7 +252,7 @@ public function processNodeDataWithoutFallbackToEmptyDimension(NodeAggregateId $
$isSiteNode = $nodeDataRow['parentpath'] === '/sites';
if ($isSiteNode && !$nodeType->isOfType(NodeTypeNameFactory::NAME_SITE)) {
throw new MigrationException(sprintf(
'The site node "%s" (type: "%s") must be of type "Neos.Neos:Site".', $nodeDataRow['identifier'], $nodeTypeName->value,
'The site node "%s" (type: "%s") must be of type "%s".', $nodeDataRow['identifier'], $nodeTypeName->value, NodeTypeNameFactory::NAME_SITE
), 1695801620);
}

Expand Down

0 comments on commit 724df3c

Please sign in to comment.