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

!!! FEATURE: Neos.Neos:Site NodeType #4563

Merged
merged 17 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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 @@ -45,14 +45,13 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\NodePath;
use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint;
use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePointSet;
use Neos\ContentRepository\Core\SharedModel\Node\PropertyName;
use Neos\ContentRepository\Core\NodeType\NodeType;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\SharedModel\User\UserId;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\Flow\Persistence\Doctrine\DataTypes\JsonArrayType;
use Neos\Flow\Property\PropertyMapper;
use Neos\Neos\Domain\Service\NodeTypeNameFactory;
use Ramsey\Uuid\Uuid;
use Webmozart\Assert\Assert;

Expand Down Expand Up @@ -87,7 +86,7 @@ public function __construct(
private readonly Filesystem $files,
private readonly iterable $nodeDataRows,
) {
$this->sitesNodeTypeName = NodeTypeName::fromString('Neos.Neos:Sites');
$this->sitesNodeTypeName = NodeTypeName::forSites();
$this->contentStreamId = ContentStreamId::create();
$this->visitedNodes = new VisitedNodeAggregates();
}
Expand All @@ -99,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 @@ -243,6 +249,13 @@ public function processNodeDataWithoutFallbackToEmptyDimension(NodeAggregateId $
$nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName);
$serializedPropertyValuesAndReferences = $this->extractPropertyValuesAndReferences($nodeDataRow, $nodeType);

$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 "%s".', $nodeDataRow['identifier'], $nodeTypeName->value, NodeTypeNameFactory::NAME_SITE
), 1695801620);
}

if ($this->isAutoCreatedChildNode($parentNodeAggregate->nodeTypeName, $nodeName) && !$this->visitedNodes->containsNodeAggregate($nodeAggregateId)) {
// Create tethered node if the node was not found before.
// If the node was already visited, we want to create a node variant (and keep the tethering status)
Expand Down
2 changes: 1 addition & 1 deletion Neos.Neos/Classes/Command/SiteCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function createCommand($name, $packageKey, $nodeType, $nodeName = null, $
} catch (SiteNodeTypeIsInvalid $exception) {
$this->outputLine(
'<error>The given node type "%s" is not based on the superType "%s"</error>',
[$nodeType, NodeTypeNameFactory::forSite()]
[$nodeType, NodeTypeNameFactory::NAME_SITE]
);
$this->quit(1);
} catch (SiteNodeNameIsAlreadyInUseByAnotherSite | NodeNameIsAlreadyOccupied $exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ public function createSiteNodeAction($packageKey, $siteName, $nodeType)
$this->addFlashMessage(
$this->getModuleLabel(
'sites.siteCreationError.givenNodeTypeNotBasedOnSuperType.body',
[$nodeType, NodeTypeNameFactory::forSite()]
[$nodeType, NodeTypeNameFactory::NAME_SITE]
),
$this->getModuleLabel('sites.siteCreationError.givenNodeTypeNotBasedOnSuperType.title'),
Message::SEVERITY_ERROR,
Expand Down
29 changes: 0 additions & 29 deletions Neos.Neos/Classes/Domain/Exception/CurrentUserIsMissing.php

This file was deleted.

29 changes: 0 additions & 29 deletions Neos.Neos/Classes/Domain/Exception/LiveWorkspaceIsMissing.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static function becauseItIsNotOfTypeSite(NodeTypeName $attemptedNodeTypeN
{
return new self(
'Node type name "' . $attemptedNodeTypeName->value
. '" is not of required type "' . NodeTypeNameFactory::forSite()->value . '"',
. '" is not of required type "' . NodeTypeNameFactory::NAME_SITE . '"',
1412372375
);
}
Expand Down
30 changes: 0 additions & 30 deletions Neos.Neos/Classes/Domain/Exception/SitesNodeIsMissing.php

This file was deleted.

29 changes: 12 additions & 17 deletions Neos.Neos/Classes/Domain/Service/SiteServiceInternals.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,22 @@
namespace Neos\Neos\Domain\Service;

use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\DimensionSpace\ContentDimensionZookeeper;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentRepository\Core\DimensionSpace\InterDimensionalVariationGraph;
use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint;
use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceInterface;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFoundException;
use Neos\ContentRepository\Core\SharedModel\Node\NodeVariantSelectionStrategy;
use Neos\ContentRepository\Core\Feature\NodeModification\Dto\PropertyValuesToWrite;
use Neos\ContentRepository\Core\Feature\NodeCreation\Command\CreateNodeAggregateWithNode;
use Neos\ContentRepository\Core\Feature\NodeModification\Dto\PropertyValuesToWrite;
use Neos\ContentRepository\Core\Feature\NodeRemoval\Command\RemoveNodeAggregate;
use Neos\ContentRepository\Core\Feature\NodeVariation\Command\CreateNodeVariant;
use Neos\ContentRepository\Core\Feature\RootNodeCreation\Command\CreateRootNodeAggregateWithNode;
use Neos\ContentRepository\Core\Feature\WorkspaceCreation\Command\CreateRootWorkspace;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate;
use Neos\ContentRepository\Core\Projection\Workspace\Workspace;
use Neos\ContentRepository\Core\Service\ContentRepositoryBootstrapper;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFoundException;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\SharedModel\User\UserId;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceDescription;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceTitle;
use Neos\Neos\Domain\Exception\LiveWorkspaceIsMissing;
use Neos\Neos\Domain\Exception\SitesNodeIsMissing;
use Neos\ContentRepository\Core\SharedModel\Node\NodeVariantSelectionStrategy;
use Neos\Neos\Domain\Exception\SiteNodeTypeIsInvalid;
use Neos\Neos\Domain\Model\Site;
use Neos\Neos\Domain\Model\SiteNodeName;

Expand Down Expand Up @@ -105,6 +95,11 @@ public function createSiteNodeIfNotExists(Site $site, string $nodeTypeName): voi
1412372375
);
}

if (!$siteNodeType->isOfType(NodeTypeNameFactory::NAME_SITE)) {
throw SiteNodeTypeIsInvalid::becauseItIsNotOfTypeSite(NodeTypeName::fromString($nodeTypeName));
}

$siteNodeAggregate = $this->contentRepository->getContentGraph()->findChildNodeAggregatesByName(
$liveContentStreamId,
$sitesNodeIdentifier,
Expand Down
3 changes: 0 additions & 3 deletions Neos.Neos/Configuration/NodeTypes.Sites.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions Neos.Neos/NodeTypes/Mixin/Document.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
constraints:
nodeTypes:
'*': false
# explicitly disallow to create a homepage below a regular document
'Neos.Neos:Site': false
'Neos.Neos:Document': true
postprocessors:
'CreationDialogPostprocessor':
Expand Down
10 changes: 10 additions & 0 deletions Neos.Neos/NodeTypes/Mixin/Site.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# Abstract NodeType for a Neos.Neos site.
# Each homepage must extend this NodeType.
# Nodes of this type must be direct children of the Neos.Neos:Site Root
# and must not be created at any other place in the tree.
#
'Neos.Neos:Site':
abstract: true
superTypes:
'Neos.Neos:Document': true
mhsdesign marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 11 additions & 0 deletions Neos.Neos/NodeTypes/Mixin/Sites.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# Root NodeType for a Neos.Neos content repository.
# Any Neos Site node must be its direct child.
#
'Neos.Neos:Sites':
superTypes:
'Neos.ContentRepository:Root': true
constraints:
nodeTypes:
'*': false
'Neos.Neos:Site': true