From d1eb6ab3d16bf0981cfff31bc8a9a29d69a42350 Mon Sep 17 00:00:00 2001 From: Bernhard Schmitt Date: Fri, 1 Sep 2023 15:42:09 +0200 Subject: [PATCH 01/26] Replace Node::nodeType access where possible and introduce fallback handling trait Also remove access on NodeType::getName() --- ...yStringNodeBasedNodeTypeManagerFactory.php | 2 +- .../Classes/NodeType/NodeType.php | 2 +- .../Classes/Projection/ContentGraph/Node.php | 27 ++++++++++------ .../Privilege/Node/CreateNodePrivilege.php | 2 +- .../Privilege/Node/NodePrivilegeContext.php | 5 ++- .../Command/ContentCommandController.php | 5 +-- .../Controller/Backend/ContentController.php | 8 +++-- .../Controller/Frontend/NodeController.php | 7 +++-- .../Management/WorkspacesController.php | 13 +++++--- .../Service/NodeSiteResolvingService.php | 7 +++-- .../Domain/Service/NodeTypeNameFactory.php | 6 ++++ .../Domain/Service/SiteNodeUtility.php | 10 ++++-- .../Domain/Service/SiteServiceInternals.php | 2 +- .../ContentRepositoryIntegrationService.php | 5 ++- .../Fusion/Cache/ContentCacheFlusher.php | 2 +- .../Classes/Fusion/Helper/NodeHelper.php | 18 +++++------ .../Classes/Fusion/Helper/NodeLabelToken.php | 14 +++++++-- .../Classes/Fusion/PluginImplementation.php | 2 +- .../DefaultPropertyEditorPostprocessor.php | 2 +- .../Routing/Cache/RouteCacheFlusher.php | 12 ++++++- .../Mapping/NodeTypeStringConverter.php | 2 +- .../Classes/Service/NodeTypeSchemaBuilder.php | 4 +-- .../Utility/NodeTypeWithFallbackProvider.php | 31 +++++++++++++++++++ Neos.Neos/Classes/View/FusionView.php | 4 ++- .../DocumentBreadcrumbPathViewHelper.php | 5 ++- .../ViewHelpers/Link/NodeViewHelper.php | 4 ++- .../NodeTypes/{Content => }/FallbackNode.yaml | 0 .../Root/Sites.yaml} | 0 28 files changed, 147 insertions(+), 54 deletions(-) create mode 100644 Neos.Neos/Classes/Utility/NodeTypeWithFallbackProvider.php rename Neos.Neos/NodeTypes/{Content => }/FallbackNode.yaml (100%) rename Neos.Neos/{Configuration/NodeTypes.Sites.yaml => NodeTypes/Root/Sites.yaml} (100%) diff --git a/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/GherkinPyStringNodeBasedNodeTypeManagerFactory.php b/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/GherkinPyStringNodeBasedNodeTypeManagerFactory.php index 4bc5bd2cdb3..cb97583cc43 100644 --- a/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/GherkinPyStringNodeBasedNodeTypeManagerFactory.php +++ b/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/GherkinPyStringNodeBasedNodeTypeManagerFactory.php @@ -54,7 +54,7 @@ public function create(NodeType $nodeType): NodeLabelGeneratorInterface return new class implements NodeLabelGeneratorInterface { public function getLabel(Node $node): string { - return $node->nodeType->getLabel(); + return $node->nodeTypeName->value; } }; } diff --git a/Neos.ContentRepository.Core/Classes/NodeType/NodeType.php b/Neos.ContentRepository.Core/Classes/NodeType/NodeType.php index 91f4d254b78..1099e8c6a38 100644 --- a/Neos.ContentRepository.Core/Classes/NodeType/NodeType.php +++ b/Neos.ContentRepository.Core/Classes/NodeType/NodeType.php @@ -668,7 +668,7 @@ protected function traverseSuperTypes( string $constraintNodeTypeName, int $distance ): ?int { - if ($currentNodeType->getName() === $constraintNodeTypeName) { + if ($currentNodeType->name->value === $constraintNodeTypeName) { return $distance; } diff --git a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php index 428b6c01933..50934dc01f8 100644 --- a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php +++ b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php @@ -34,13 +34,13 @@ * * @api Note: The constructor is not part of the public API */ -final class Node +final readonly class Node { /** * @internal */ public function __construct( - public readonly ContentSubgraphIdentity $subgraphIdentity, + public ContentSubgraphIdentity $subgraphIdentity, /** * NodeAggregateId (identifier) of this node * This is part of the node's "Read Model" identity, whis is defined by: @@ -50,15 +50,22 @@ public function __construct( * With the above information, you can fetch a Subgraph using {@see ContentGraphInterface::getSubgraph()}. * or {@see \Neos\ContentRepositoryRegistry\ContentRepositoryRegistry::subgraphForNode()} */ - public readonly NodeAggregateId $nodeAggregateId, + public NodeAggregateId $nodeAggregateId, /** * returns the DimensionSpacePoint the node is at home in. Usually needed to address a Node in a NodeAggregate * in order to update it. */ - public readonly OriginDimensionSpacePoint $originDimensionSpacePoint, - public readonly NodeAggregateClassification $classification, - public readonly NodeTypeName $nodeTypeName, - public readonly NodeType $nodeType, + public OriginDimensionSpacePoint $originDimensionSpacePoint, + public NodeAggregateClassification $classification, + /** + * The node's node type name; always set, even if unknown to the NodeTypeManager + */ + public NodeTypeName $nodeTypeName, + /** + * The node's node type, null if unknown to the NodeTypeManager + * @deprecated Ask the NodeTypeManager instead + */ + public ?NodeType $nodeType, /** * Returns all properties of this node. References are NOT part of this API; * there you need to check getReference() and getReferences(). @@ -67,9 +74,9 @@ public function __construct( * * @return PropertyCollectionInterface Property values, indexed by their name */ - public readonly PropertyCollectionInterface $properties, - public readonly ?NodeName $nodeName, - public readonly Timestamps $timestamps, + public PropertyCollectionInterface $properties, + public ?NodeName $nodeName, + public Timestamps $timestamps, ) { } diff --git a/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/CreateNodePrivilege.php b/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/CreateNodePrivilege.php index cbbfd195d58..42e2780a4ef 100644 --- a/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/CreateNodePrivilege.php +++ b/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/CreateNodePrivilege.php @@ -77,7 +77,7 @@ public function matchesSubject(PrivilegeSubjectInterface $subject): bool if ($this->nodeContext->getCreationNodeTypes() === [] || ($subject->hasCreationNodeType() === false) || !is_null($creationNodeType) && in_array( - $creationNodeType->getName(), + $creationNodeType->name->value, $this->nodeContext->getCreationNodeTypes() ) === true) { return parent::matchesSubject($subject); diff --git a/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php b/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php index 30d267a93f2..7a8c370ebf7 100644 --- a/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php +++ b/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php @@ -20,12 +20,15 @@ use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Flow\Security\Context as SecurityContext; +use Neos\Neos\Utility\NodeTypeWithFallbackProvider; /** * An Eel context matching expression for the node privileges */ class NodePrivilegeContext { + use NodeTypeWithFallbackProvider; + /** * @Flow\Inject * @var SecurityContext @@ -143,7 +146,7 @@ public function nodeIsOfType(string|array $nodeTypes): bool } foreach ($nodeTypes as $nodeType) { - if ($this->node->nodeType->isOfType($nodeType)) { + if ($this->getNodeType($this->node)->isOfType($nodeType)) { return true; } } diff --git a/Neos.ContentRepositoryRegistry/Classes/Command/ContentCommandController.php b/Neos.ContentRepositoryRegistry/Classes/Command/ContentCommandController.php index 3a230621e46..391e8edcaac 100644 --- a/Neos.ContentRepositoryRegistry/Classes/Command/ContentCommandController.php +++ b/Neos.ContentRepositoryRegistry/Classes/Command/ContentCommandController.php @@ -148,7 +148,8 @@ private function createVariantRecursivelyInternal(int $level, NodeAggregateId $p foreach ($childNodes as $childNode) { if ($childNode->classification->isRegular()) { - if ($childNode->nodeType->isOfType('Neos.Neos:Document')) { + $childNodeType = $contentRepository->getNodeTypeManager()->getNodeType($childNode->nodeTypeName); + if ($childNodeType->isOfType('Neos.Neos:Document')) { $this->output("%s- %s\n", [ str_repeat(' ', $level), $childNode->getProperty('uriPathSegment') ?? $childNode->nodeAggregateId->value @@ -163,7 +164,7 @@ private function createVariantRecursivelyInternal(int $level, NodeAggregateId $p $target ))->block(); } catch (DimensionSpacePointIsAlreadyOccupied $e) { - if ($childNode->nodeType->isOfType('Neos.Neos:Document')) { + if ($childNodeType->isOfType('Neos.Neos:Document')) { $this->output("%s (already exists)\n", [ str_repeat(' ', $level) ]); diff --git a/Neos.Neos/Classes/Controller/Backend/ContentController.php b/Neos.Neos/Classes/Controller/Backend/ContentController.php index 431ebe35270..c18dfee533c 100644 --- a/Neos.Neos/Classes/Controller/Backend/ContentController.php +++ b/Neos.Neos/Classes/Controller/Backend/ContentController.php @@ -45,6 +45,7 @@ use Neos\Neos\Controller\BackendUserTranslationTrait; use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult; use Neos\Neos\TypeConverter\EntityToIdentityConverter; +use Neos\Neos\Utility\NodeTypeWithFallbackProvider; /** * The Neos ContentModule controller; providing backend functionality for the Content Module. @@ -54,6 +55,7 @@ class ContentController extends ActionController { use BackendUserTranslationTrait; + use NodeTypeWithFallbackProvider; /** * @Flow\Inject @@ -413,12 +415,12 @@ public function masterPluginsAction(string $workspaceName = 'live', array $dimen final protected function findClosestDocumentNode(Node $node): ?Node { + $subgraph = $this->contentRepositoryRegistry->subgraphForNode($node); while ($node instanceof Node) { - if ($node->nodeType->isOfType('Neos.Neos:Document')) { + if ($this->getNodeType($node)->isOfType('Neos.Neos:Document')) { return $node; } - $node = $this->contentRepositoryRegistry->subgraphForNode($node) - ->findParentNode($node->nodeAggregateId); + $node = $subgraph->findParentNode($node->nodeAggregateId); } return null; diff --git a/Neos.Neos/Classes/Controller/Frontend/NodeController.php b/Neos.Neos/Classes/Controller/Frontend/NodeController.php index f529f9f3844..5372341184c 100644 --- a/Neos.Neos/Classes/Controller/Frontend/NodeController.php +++ b/Neos.Neos/Classes/Controller/Frontend/NodeController.php @@ -43,6 +43,7 @@ use Neos\Neos\FrontendRouting\NodeShortcutResolver; use Neos\Neos\FrontendRouting\NodeUriBuilder; use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult; +use Neos\Neos\Utility\NodeTypeWithFallbackProvider; use Neos\Neos\View\FusionView; /** @@ -50,6 +51,8 @@ */ class NodeController extends ActionController { + use NodeTypeWithFallbackProvider; + /** * @Flow\Inject * @var ContentRepositoryRegistry @@ -157,7 +160,7 @@ public function previewAction(string $node): void ); } - if ($nodeInstance->nodeType->isOfType('Neos.Neos:Shortcut') && $nodeAddress->isInLiveWorkspace()) { + if ($this->getNodeType($nodeInstance)->isOfType('Neos.Neos:Shortcut') && $nodeAddress->isInLiveWorkspace()) { $this->handleShortcutNode($nodeAddress, $contentRepository); } @@ -230,7 +233,7 @@ public function showAction(string $node, bool $showInvisible = false): void throw new NodeNotFoundException('The requested node does not exist', 1596191460); } - if ($nodeInstance->nodeType->isOfType('Neos.Neos:Shortcut')) { + if ($this->getNodeType($nodeInstance)->isOfType('Neos.Neos:Shortcut')) { $this->handleShortcutNode($nodeAddress, $contentRepository); } diff --git a/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php b/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php index f31234019a7..76c4a5ccc21 100644 --- a/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php +++ b/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php @@ -62,6 +62,7 @@ use Neos\Neos\Domain\Repository\SiteRepository; use Neos\Neos\Domain\Service\UserService; use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult; +use Neos\Neos\Utility\NodeTypeWithFallbackProvider; /** * The Neos Workspaces module controller @@ -71,6 +72,7 @@ class WorkspacesController extends AbstractModuleController { use ModuleTranslationTrait; + use NodeTypeWithFallbackProvider; /** * @Flow\Inject @@ -793,7 +795,7 @@ protected function computeSiteChanges(Workspace $selectedWorkspace, ContentRepos foreach ($ancestors as $ancestor) { $pathSegment = $ancestor->nodeName ?: NodeName::fromString($ancestor->nodeAggregateId->value); $nodePathSegments[] = $pathSegment; - if ($ancestor->nodeType->isOfType('Neos.Neos:Document')) { + if ($this->getNodeType($ancestor)->isOfType('Neos.Neos:Document')) { $documentPathSegments[] = $pathSegment; if (is_null($documentNode)) { $documentNode = $ancestor; @@ -836,8 +838,9 @@ protected function computeSiteChanges(Workspace $selectedWorkspace, ContentRepos $contentRepository ) ]; - if ($node->nodeType->isOfType('Neos.Neos:Node')) { - $change['configuration'] = $node->nodeType->getFullConfiguration(); + $nodeType = $this->getNodeType($node); + if ($nodeType->isOfType('Neos.Neos:Node')) { + $change['configuration'] = $nodeType->getFullConfiguration(); } $siteChanges[$siteNodeName]['documents'][$documentPath]['changes'][$relativePath] = $change; } @@ -907,7 +910,7 @@ protected function renderContentChanges( $contentChanges = []; - $changeNodePropertiesDefaults = $changedNode->nodeType->getDefaultValuesForProperties(); + $changeNodePropertiesDefaults = $this->getNodeType($changedNode)->getDefaultValuesForProperties(); $renderer = new HtmlArrayRenderer(); foreach ($changedNode->properties as $propertyName => $changedPropertyValue) { @@ -1024,7 +1027,7 @@ protected function renderSlimmedDownContent($propertyValue) */ protected function getPropertyLabel($propertyName, Node $changedNode) { - $properties = $changedNode->nodeType->getProperties(); + $properties = $this->getNodeType($changedNode)->getProperties(); if ( !isset($properties[$propertyName]) || !isset($properties[$propertyName]['ui']['label']) diff --git a/Neos.Neos/Classes/Domain/Service/NodeSiteResolvingService.php b/Neos.Neos/Classes/Domain/Service/NodeSiteResolvingService.php index 0807b96ccd3..2d66165c41d 100644 --- a/Neos.Neos/Classes/Domain/Service/NodeSiteResolvingService.php +++ b/Neos.Neos/Classes/Domain/Service/NodeSiteResolvingService.php @@ -21,10 +21,13 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints; use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; +use Neos\Neos\Utility\NodeTypeWithFallbackProvider; #[Flow\Scope('singleton')] class NodeSiteResolvingService { + use NodeTypeWithFallbackProvider; + /** * @Flow\Inject * @var ContentRepositoryRegistry @@ -51,8 +54,8 @@ public function findSiteNodeForNodeAddress( } $previousNode = null; do { - if ($node->nodeType->isOfType('Neos.Neos:Sites')) { - // the Site node is the one one level underneath the "Sites" node. + if ($this->getNodeType($node)->isOfType(NodeTypeNameFactory::NAME_SITES)) { + // the Site node is the one level underneath the "Sites" node. return $previousNode; } $previousNode = $node; diff --git a/Neos.Neos/Classes/Domain/Service/NodeTypeNameFactory.php b/Neos.Neos/Classes/Domain/Service/NodeTypeNameFactory.php index 67542aa2327..b1f8caadb0f 100644 --- a/Neos.Neos/Classes/Domain/Service/NodeTypeNameFactory.php +++ b/Neos.Neos/Classes/Domain/Service/NodeTypeNameFactory.php @@ -23,6 +23,7 @@ final class NodeTypeNameFactory public const NAME_DOCUMENT = 'Neos.Neos:Document'; public const NAME_SITE = 'Neos.Neos:Site'; public const NAME_SITES = 'Neos.Neos:Sites'; + public const NAME_CONTENT_COLLECTION = 'Neos.Neos:ContentCollection'; public const NAME_FALLBACK = 'Neos.Neos:FallbackNode'; public static function forDocument(): NodeTypeName @@ -40,6 +41,11 @@ public static function forSites(): NodeTypeName return NodeTypeName::fromString(self::NAME_SITES); } + public static function forContentCollection(): NodeTypeName + { + return NodeTypeName::fromString(self::NAME_CONTENT_COLLECTION); + } + public static function forFallback(): NodeTypeName { return NodeTypeName::fromString(self::NAME_FALLBACK); diff --git a/Neos.Neos/Classes/Domain/Service/SiteNodeUtility.php b/Neos.Neos/Classes/Domain/Service/SiteNodeUtility.php index e676f4579c0..d68a8ae48b2 100644 --- a/Neos.Neos/Classes/Domain/Service/SiteNodeUtility.php +++ b/Neos.Neos/Classes/Domain/Service/SiteNodeUtility.php @@ -26,15 +26,19 @@ use Neos\Neos\Domain\Model\Site; use Neos\Neos\Domain\Repository\DomainRepository; use Neos\Neos\Domain\Repository\SiteRepository; +use Neos\Neos\Utility\NodeTypeWithFallbackProvider; #[Flow\Scope('singleton')] final class SiteNodeUtility { + use NodeTypeWithFallbackProvider; + public function __construct( - private readonly ContentRepositoryRegistry $contentRepositoryRegistry, + ContentRepositoryRegistry $contentRepositoryRegistry, private readonly DomainRepository $domainRepository, private readonly SiteRepository $siteRepository ) { + $this->contentRepositoryRegistry = $contentRepositoryRegistry; } public function findSiteNode(Node $node): Node @@ -42,8 +46,8 @@ public function findSiteNode(Node $node): Node $previousNode = null; $subgraph = $this->contentRepositoryRegistry->subgraphForNode($node); do { - if ($node->nodeType->isOfType('Neos.Neos:Sites')) { - // the Site node is the one one level underneath the "Sites" node. + if ($this->getNodeType($node)->isOfType('Neos.Neos:Sites')) { + // the Site node is the one level underneath the "Sites" node. if (is_null($previousNode)) { break; } diff --git a/Neos.Neos/Classes/Domain/Service/SiteServiceInternals.php b/Neos.Neos/Classes/Domain/Service/SiteServiceInternals.php index 36b2f57dfa9..5e108410766 100644 --- a/Neos.Neos/Classes/Domain/Service/SiteServiceInternals.php +++ b/Neos.Neos/Classes/Domain/Service/SiteServiceInternals.php @@ -99,7 +99,7 @@ public function createSiteNodeIfNotExists(Site $site, string $nodeTypeName): voi ); $siteNodeType = $this->nodeTypeManager->getNodeType($nodeTypeName); - if ($siteNodeType->getName() === 'Neos.Neos:FallbackNode') { + if ($siteNodeType->name === NodeTypeNameFactory::forFallback()) { throw new NodeTypeNotFoundException( 'Cannot create a site using a non-existing node type.', 1412372375 diff --git a/Neos.Neos/Classes/EventLog/Integrations/ContentRepositoryIntegrationService.php b/Neos.Neos/Classes/EventLog/Integrations/ContentRepositoryIntegrationService.php index 1fc2ec1bd52..17889f30647 100644 --- a/Neos.Neos/Classes/EventLog/Integrations/ContentRepositoryIntegrationService.php +++ b/Neos.Neos/Classes/EventLog/Integrations/ContentRepositoryIntegrationService.php @@ -21,6 +21,7 @@ use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Flow\Persistence\PersistenceManagerInterface; +use Neos\Neos\Utility\NodeTypeWithFallbackProvider; /** * Monitors Neos.ContentRepository changes @@ -30,6 +31,8 @@ */ class ContentRepositoryIntegrationService extends AbstractIntegrationService { + use NodeTypeWithFallbackProvider; + public const NODE_ADDED = 'Node.Added'; public const NODE_UPDATED = 'Node.Updated'; public const NODE_LABEL_CHANGED = 'Node.LabelChanged'; @@ -412,7 +415,7 @@ public function afterNodePublishing(Node $node, Workspace $targetWorkspace) $subgraph = $this->contentRepositoryRegistry->subgraphForNode($node); $documentNode = $node; - while ($documentNode !== null && !$documentNode->nodeType->isAggregate()) { + while ($documentNode !== null && !$this->getNodeType($documentNode)->isAggregate()) { $documentNode = $subgraph->findParentNode($documentNode->nodeAggregateId); } diff --git a/Neos.Neos/Classes/Fusion/Cache/ContentCacheFlusher.php b/Neos.Neos/Classes/Fusion/Cache/ContentCacheFlusher.php index 71a64e4a356..e66d617b834 100644 --- a/Neos.Neos/Classes/Fusion/Cache/ContentCacheFlusher.php +++ b/Neos.Neos/Classes/Fusion/Cache/ContentCacheFlusher.php @@ -255,7 +255,7 @@ protected function getAllImplementedNodeTypeNames(NodeType $nodeType) function (array $types, NodeType $superType) use ($self) { return array_merge($types, $self->getAllImplementedNodeTypeNames($superType)); }, - [$nodeType->getName()] + [$nodeType->name->value] ); $types = array_unique($types); diff --git a/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php b/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php index b7fbf538ba6..40df534afe2 100644 --- a/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php +++ b/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php @@ -18,6 +18,7 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\CountAncestorNodesFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindAncestorNodesFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\NodePath; +use Neos\Neos\Domain\Service\NodeTypeNameFactory; use Neos\Neos\FrontendRouting\NodeAddressFactory; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; @@ -25,12 +26,15 @@ use Neos\Eel\ProtectedContextAwareInterface; use Neos\Neos\Domain\Exception; use Neos\Neos\Presentation\VisualNodePath; +use Neos\Neos\Utility\NodeTypeWithFallbackProvider; /** * Eel helper for ContentRepository Nodes */ class NodeHelper implements ProtectedContextAwareInterface { + use NodeTypeWithFallbackProvider; + /** * @Flow\Inject * @var ContentRepositoryRegistry @@ -45,8 +49,8 @@ class NodeHelper implements ProtectedContextAwareInterface */ public function nearestContentCollection(Node $node, string $nodePath): Node { - $contentCollectionType = 'Neos.Neos:ContentCollection'; - if ($node->nodeType->isOfType($contentCollectionType)) { + $contentCollectionType = NodeTypeNameFactory::NAME_CONTENT_COLLECTION; + if ($this->isOfType($node, $contentCollectionType)) { return $node; } else { if ($nodePath === '') { @@ -66,7 +70,7 @@ public function nearestContentCollection(Node $node, string $nodePath): Node ? $subgraph->findNodeByAbsolutePath($nodePath) : $subgraph->findNodeByPath($nodePath, $node->nodeAggregateId); - if ($subNode !== null && $subNode->nodeType->isOfType($contentCollectionType)) { + if ($subNode !== null && $this->isOfType($subNode, $contentCollectionType)) { return $subNode; } else { $nodePathOfNode = VisualNodePath::fromAncestors( @@ -84,7 +88,7 @@ public function nearestContentCollection(Node $node, string $nodePath): Node $contentCollectionType, $nodePathOfNode->value, $nodePath->serializeToString(), - $node->nodeType->name->value + $node->nodeTypeName->value ), 1389352984); } } @@ -140,14 +144,10 @@ public function isLive(Node $node): bool /** * If this node type or any of the direct or indirect super types * has the given name. - * - * @param Node $node - * @param string $nodeType - * @return bool */ public function isOfType(Node $node, string $nodeType): bool { - return $node->nodeType->isOfType($nodeType); + return $this->getNodeType($node)->isOfType($nodeType); } public function serializedNodeAddress(Node $node): string diff --git a/Neos.Neos/Classes/Fusion/Helper/NodeLabelToken.php b/Neos.Neos/Classes/Fusion/Helper/NodeLabelToken.php index b68638890f4..6b2ad6a57c5 100644 --- a/Neos.Neos/Classes/Fusion/Helper/NodeLabelToken.php +++ b/Neos.Neos/Classes/Fusion/Helper/NodeLabelToken.php @@ -15,10 +15,12 @@ namespace Neos\Neos\Fusion\Helper; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; +use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Eel\Helper\StringHelper; use Neos\Eel\ProtectedContextAwareInterface; use Neos\Flow\Annotations as Flow; use Neos\Flow\I18n\EelHelper\TranslationHelper; +use Neos\Neos\Utility\NodeTypeWithFallbackProvider; /** * Provides a chainable interface to build a label for a nodetype @@ -26,6 +28,8 @@ */ class NodeLabelToken implements ProtectedContextAwareInterface { + use NodeTypeWithFallbackProvider; + /** * @Flow\Inject * @var TranslationHelper @@ -38,6 +42,12 @@ class NodeLabelToken implements ProtectedContextAwareInterface */ protected $stringHelper; + /** + * @Flow\Inject + * @var ContentRepositoryRegistry + */ + protected $contentRepositoryRegistry; + /** * @var string */ @@ -140,9 +150,9 @@ public function evaluate(): string */ protected function resolveLabelFromNodeType(): void { - $this->label = $this->translationHelper->translate($this->node->nodeType->getLabel()) ?: ''; + $this->label = $this->translationHelper->translate($this->getNodeType($this->node)->getLabel()) ?: ''; if (empty($this->label)) { - $this->label = $this->node->nodeType->getName(); + $this->label = $this->node->nodeTypeName->value; } if (empty($this->postfix) && $this->node->nodeName !== null && $this->node->classification->isTethered()) { diff --git a/Neos.Neos/Classes/Fusion/PluginImplementation.php b/Neos.Neos/Classes/Fusion/PluginImplementation.php index fc9a0da7e74..43db3bcbdf2 100644 --- a/Neos.Neos/Classes/Fusion/PluginImplementation.php +++ b/Neos.Neos/Classes/Fusion/PluginImplementation.php @@ -198,7 +198,7 @@ protected function getPluginNamespace(): string return $nodeArgumentNamespace; } - $nodeArgumentNamespace = $this->node->nodeType->getName(); + $nodeArgumentNamespace = $this->node->nodeTypeName->value; $nodeArgumentNamespace = str_replace(':', '-', $nodeArgumentNamespace); $nodeArgumentNamespace = str_replace('.', '_', $nodeArgumentNamespace); $nodeArgumentNamespace = strtolower($nodeArgumentNamespace); diff --git a/Neos.Neos/Classes/NodeTypePostprocessor/DefaultPropertyEditorPostprocessor.php b/Neos.Neos/Classes/NodeTypePostprocessor/DefaultPropertyEditorPostprocessor.php index 1e1bd397c98..5011dff1227 100644 --- a/Neos.Neos/Classes/NodeTypePostprocessor/DefaultPropertyEditorPostprocessor.php +++ b/Neos.Neos/Classes/NodeTypePostprocessor/DefaultPropertyEditorPostprocessor.php @@ -47,7 +47,7 @@ class DefaultPropertyEditorPostprocessor implements NodeTypePostprocessorInterfa */ public function process(NodeType $nodeType, array &$configuration, array $options): void { - $nodeTypeName = $nodeType->getName(); + $nodeTypeName = $nodeType->name->value; if (isset($configuration['properties']) && is_array($configuration['properties'])) { foreach ($configuration['properties'] as $propertyName => &$propertyConfiguration) { if (!isset($propertyConfiguration['type'])) { diff --git a/Neos.Neos/Classes/Routing/Cache/RouteCacheFlusher.php b/Neos.Neos/Classes/Routing/Cache/RouteCacheFlusher.php index be49d9cf6cf..b950ec57998 100644 --- a/Neos.Neos/Classes/Routing/Cache/RouteCacheFlusher.php +++ b/Neos.Neos/Classes/Routing/Cache/RouteCacheFlusher.php @@ -16,8 +16,10 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\Projection\Workspace\Workspace; +use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Flow\Mvc\Routing\RouterCachingService; +use Neos\Neos\Utility\NodeTypeWithFallbackProvider; /** * This service flushes Route caches triggered by node changes. @@ -26,12 +28,20 @@ */ class RouteCacheFlusher { + use NodeTypeWithFallbackProvider; + /** * @Flow\Inject * @var RouterCachingService */ protected $routeCachingService; + /** + * @Flow\Inject + * @var ContentRepositoryRegistry + */ + protected $contentRepositoryRegistry; + /** * @var array */ @@ -50,7 +60,7 @@ public function registerNodeChange(Node $node) if (in_array($identifier, $this->tagsToFlush)) { return; } - if (!$node->nodeType->isOfType('Neos.Neos:Document')) { + if (!$this->getNodeType($node)->isOfType('Neos.Neos:Document')) { return; } $this->tagsToFlush[] = $identifier; diff --git a/Neos.Neos/Classes/Service/Mapping/NodeTypeStringConverter.php b/Neos.Neos/Classes/Service/Mapping/NodeTypeStringConverter.php index d525b32fb54..faab7553e7d 100644 --- a/Neos.Neos/Classes/Service/Mapping/NodeTypeStringConverter.php +++ b/Neos.Neos/Classes/Service/Mapping/NodeTypeStringConverter.php @@ -59,7 +59,7 @@ public function convertFrom( PropertyMappingConfigurationInterface $configuration = null ) { if ($source instanceof NodeType) { - return $source->getName(); + return $source->name->value; } return ''; diff --git a/Neos.Neos/Classes/Service/NodeTypeSchemaBuilder.php b/Neos.Neos/Classes/Service/NodeTypeSchemaBuilder.php index f3a96315ec6..e626cfd37a8 100644 --- a/Neos.Neos/Classes/Service/NodeTypeSchemaBuilder.php +++ b/Neos.Neos/Classes/Service/NodeTypeSchemaBuilder.php @@ -71,9 +71,9 @@ public function generateNodeTypeSchema() } $schema['inheritanceMap']['subTypes'][$nodeTypeName] = []; - foreach ($this->nodeTypeManager->getSubNodeTypes($nodeType->getName(), true) as $subNodeType) { + foreach ($this->nodeTypeManager->getSubNodeTypes($nodeType->name, true) as $subNodeType) { /** @var NodeType $subNodeType */ - $schema['inheritanceMap']['subTypes'][$nodeTypeName][] = $subNodeType->getName(); + $schema['inheritanceMap']['subTypes'][$nodeTypeName][] = $subNodeType->name->value; } } diff --git a/Neos.Neos/Classes/Utility/NodeTypeWithFallbackProvider.php b/Neos.Neos/Classes/Utility/NodeTypeWithFallbackProvider.php new file mode 100644 index 00000000000..9ad90f1363f --- /dev/null +++ b/Neos.Neos/Classes/Utility/NodeTypeWithFallbackProvider.php @@ -0,0 +1,31 @@ +contentRepositoryRegistry->get($node->subgraphIdentity->contentRepositoryId)->getNodeTypeManager(); + + try { + return $nodeTypeManager->getNodeType($node->nodeTypeName); + } catch (NodeTypeNotFoundException) { + return $nodeTypeManager->getNodeType(NodeTypeNameFactory::forFallback()); + } + } +} diff --git a/Neos.Neos/Classes/View/FusionView.php b/Neos.Neos/Classes/View/FusionView.php index 17c666f6f02..b90974fe759 100644 --- a/Neos.Neos/Classes/View/FusionView.php +++ b/Neos.Neos/Classes/View/FusionView.php @@ -25,6 +25,7 @@ use Neos\Neos\Domain\Service\FusionService; use Neos\Neos\Domain\Service\SiteNodeUtility; use Neos\Neos\Exception; +use Neos\Neos\Utility\NodeTypeWithFallbackProvider; use Psr\Http\Message\ResponseInterface; /** @@ -33,6 +34,7 @@ class FusionView extends AbstractView { use FusionViewI18nTrait; + use NodeTypeWithFallbackProvider; /** * @Flow\Inject @@ -177,7 +179,7 @@ public function getFusionPath() protected function getClosestDocumentNode(Node $node): ?Node { $subgraph = $this->contentRepositoryRegistry->subgraphForNode($node); - while ($node !== null && !$node->nodeType->isOfType('Neos.Neos:Document')) { + while ($node !== null && !$this->getNodeType($node)->isOfType('Neos.Neos:Document')) { $node = $subgraph->findParentNode($node->nodeAggregateId); } diff --git a/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php b/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php index 6505fe97b78..a587aeae43a 100644 --- a/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php +++ b/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php @@ -18,12 +18,15 @@ use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper; +use Neos\Neos\Utility\NodeTypeWithFallbackProvider; /** * Render a bread crumb path by using the labels of documents leading to the given node path */ class DocumentBreadcrumbPathViewHelper extends AbstractViewHelper { + use NodeTypeWithFallbackProvider; + /** * @var boolean */ @@ -50,7 +53,7 @@ public function render(): mixed $currentNode = $node; while ($currentNode instanceof Node) { - if ($currentNode->nodeType->isOfType('Neos.Neos:Document')) { + if ($this->getNodeType($currentNode)->isOfType('Neos.Neos:Document')) { $documentNodes[] = $currentNode; } $currentNode = $subgraph->findParentNode($currentNode->nodeAggregateId); diff --git a/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php b/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php index d2885f59ed4..085a36e3575 100644 --- a/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php +++ b/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php @@ -36,6 +36,7 @@ use Neos\Neos\FrontendRouting\Exception\NodeNotFoundException; use Neos\Neos\FrontendRouting\NodeShortcutResolver; use Neos\Neos\FrontendRouting\NodeUriBuilder; +use Neos\Neos\Utility\NodeTypeWithFallbackProvider; /** * A view helper for creating links with URIs pointing to nodes. @@ -125,6 +126,7 @@ class NodeViewHelper extends AbstractTagBasedViewHelper { use FusionContextTrait; + use NodeTypeWithFallbackProvider; /** * @var string @@ -298,7 +300,7 @@ public function render(): string json_encode($subgraph, JSON_PARTIAL_OUTPUT_ON_ERROR) ), 1601372444)); } - if ($resolvedNode && $resolvedNode->nodeType->isOfType('Neos.Neos:Shortcut')) { + if ($resolvedNode && $this->getNodeType($resolvedNode)->isOfType('Neos.Neos:Shortcut')) { try { $shortcutNodeAddress = $this->nodeShortcutResolver->resolveShortcutTarget( $nodeAddress, diff --git a/Neos.Neos/NodeTypes/Content/FallbackNode.yaml b/Neos.Neos/NodeTypes/FallbackNode.yaml similarity index 100% rename from Neos.Neos/NodeTypes/Content/FallbackNode.yaml rename to Neos.Neos/NodeTypes/FallbackNode.yaml diff --git a/Neos.Neos/Configuration/NodeTypes.Sites.yaml b/Neos.Neos/NodeTypes/Root/Sites.yaml similarity index 100% rename from Neos.Neos/Configuration/NodeTypes.Sites.yaml rename to Neos.Neos/NodeTypes/Root/Sites.yaml From 85d87dfa43443b7d61ec8029cb3f81578c4f9118 Mon Sep 17 00:00:00 2001 From: Bernhard Schmitt Date: Fri, 1 Sep 2023 16:13:31 +0200 Subject: [PATCH 02/26] Consistently use NodeTypeNameFactory --- .../Controller/Backend/ContentController.php | 3 ++- .../Controller/Frontend/NodeController.php | 7 ++--- .../Module/Administration/SitesController.php | 4 +-- .../Management/WorkspacesController.php | 3 ++- .../Controller/Service/NodesController.php | 5 ++-- .../Domain/Service/NodeTypeNameFactory.php | 26 ++++++++++++------- .../Domain/Service/SiteNodeUtility.php | 4 +-- .../Domain/Service/SiteServiceInternals.php | 2 +- .../Projection/DocumentUriPathProjection.php | 5 ++-- .../Fusion/MenuItemsImplementation.php | 5 ++-- .../Routing/Cache/RouteCacheFlusher.php | 3 ++- Neos.Neos/Classes/View/FusionView.php | 3 ++- .../DocumentBreadcrumbPathViewHelper.php | 3 ++- .../ViewHelpers/Link/NodeViewHelper.php | 3 ++- 14 files changed, 46 insertions(+), 30 deletions(-) diff --git a/Neos.Neos/Classes/Controller/Backend/ContentController.php b/Neos.Neos/Classes/Controller/Backend/ContentController.php index c18dfee533c..a0c24e8c7aa 100644 --- a/Neos.Neos/Classes/Controller/Backend/ContentController.php +++ b/Neos.Neos/Classes/Controller/Backend/ContentController.php @@ -17,6 +17,7 @@ use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; +use Neos\Neos\Domain\Service\NodeTypeNameFactory; use Neos\Neos\FrontendRouting\NodeAddressFactory; use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints; use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; @@ -417,7 +418,7 @@ final protected function findClosestDocumentNode(Node $node): ?Node { $subgraph = $this->contentRepositoryRegistry->subgraphForNode($node); while ($node instanceof Node) { - if ($this->getNodeType($node)->isOfType('Neos.Neos:Document')) { + if ($this->getNodeType($node)->isOfType(NodeTypeNameFactory::NAME_DOCUMENT)) { return $node; } $node = $subgraph->findParentNode($node->nodeAggregateId); diff --git a/Neos.Neos/Classes/Controller/Frontend/NodeController.php b/Neos.Neos/Classes/Controller/Frontend/NodeController.php index 5372341184c..cc477ca9f47 100644 --- a/Neos.Neos/Classes/Controller/Frontend/NodeController.php +++ b/Neos.Neos/Classes/Controller/Frontend/NodeController.php @@ -36,6 +36,7 @@ use Neos\Flow\Session\SessionInterface; use Neos\Flow\Utility\Now; use Neos\Neos\Domain\Service\NodeSiteResolvingService; +use Neos\Neos\Domain\Service\NodeTypeNameFactory; use Neos\Neos\FrontendRouting\Exception\InvalidShortcutException; use Neos\Neos\FrontendRouting\Exception\NodeNotFoundException; use Neos\Neos\FrontendRouting\NodeAddress; @@ -160,7 +161,7 @@ public function previewAction(string $node): void ); } - if ($this->getNodeType($nodeInstance)->isOfType('Neos.Neos:Shortcut') && $nodeAddress->isInLiveWorkspace()) { + if ($this->getNodeType($nodeInstance)->isOfType(NodeTypeNameFactory::NAME_SHORTCUT) && $nodeAddress->isInLiveWorkspace()) { $this->handleShortcutNode($nodeAddress, $contentRepository); } @@ -233,7 +234,7 @@ public function showAction(string $node, bool $showInvisible = false): void throw new NodeNotFoundException('The requested node does not exist', 1596191460); } - if ($this->getNodeType($nodeInstance)->isOfType('Neos.Neos:Shortcut')) { + if ($this->getNodeType($nodeInstance)->isOfType(NodeTypeNameFactory::NAME_SHORTCUT)) { $this->handleShortcutNode($nodeAddress, $contentRepository); } @@ -327,7 +328,7 @@ private function fillCacheWithContentNodes( $subtree = $subgraph->findSubtree( $nodeAggregateId, - FindSubtreeFilter::create(nodeTypeConstraints: '!Neos.Neos:Document', maximumLevels: 20) + FindSubtreeFilter::create(nodeTypeConstraints: '!' . NodeTypeNameFactory::NAME_DOCUMENT, maximumLevels: 20) ); if ($subtree === null) { return; diff --git a/Neos.Neos/Classes/Controller/Module/Administration/SitesController.php b/Neos.Neos/Classes/Controller/Module/Administration/SitesController.php index c6cb292fc97..9eef8476993 100755 --- a/Neos.Neos/Classes/Controller/Module/Administration/SitesController.php +++ b/Neos.Neos/Classes/Controller/Module/Administration/SitesController.php @@ -186,7 +186,7 @@ public function updateSiteAction(Site $site, $newSiteNodeName) try { $sitesNode = $contentRepository->getContentGraph()->findRootNodeAggregateByType( $liveWorkspace->currentContentStreamId, - NodeTypeName::fromString('Neos.Neos:Sites') + NodeTypeNameFactory::forSites() ); } catch (\Exception $exception) { throw new \InvalidArgumentException( @@ -253,7 +253,7 @@ public function newSiteAction(Site $site = null) $sitePackages = $this->packageManager->getFilteredPackages('available', 'neos-site'); - $documentNodeTypes = $contentRepository->getNodeTypeManager()->getSubNodeTypes('Neos.Neos:Document', false); + $documentNodeTypes = $contentRepository->getNodeTypeManager()->getSubNodeTypes(NodeTypeNameFactory::forDocument(), false); $generatorServiceIsAvailable = $this->packageManager->isPackageAvailable('Neos.SiteKickstarter'); $generatorServices = []; diff --git a/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php b/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php index 76c4a5ccc21..24d720131a3 100644 --- a/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php +++ b/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php @@ -25,6 +25,7 @@ use Neos\Flow\I18n\Exception\InvalidFormatPlaceholderException; use Neos\Flow\Mvc\Exception\StopActionException; use Neos\Neos\Domain\Model\SiteNodeName; +use Neos\Neos\Domain\Service\NodeTypeNameFactory; use Neos\Neos\PendingChangesProjection\ChangeFinder; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\Projection\Workspace\Workspace; @@ -795,7 +796,7 @@ protected function computeSiteChanges(Workspace $selectedWorkspace, ContentRepos foreach ($ancestors as $ancestor) { $pathSegment = $ancestor->nodeName ?: NodeName::fromString($ancestor->nodeAggregateId->value); $nodePathSegments[] = $pathSegment; - if ($this->getNodeType($ancestor)->isOfType('Neos.Neos:Document')) { + if ($this->getNodeType($ancestor)->isOfType(NodeTypeNameFactory::NAME_DOCUMENT)) { $documentPathSegments[] = $pathSegment; if (is_null($documentNode)) { $documentNode = $ancestor; diff --git a/Neos.Neos/Classes/Controller/Service/NodesController.php b/Neos.Neos/Classes/Controller/Service/NodesController.php index 6505e7ea22a..060fec28fbc 100644 --- a/Neos.Neos/Classes/Controller/Service/NodesController.php +++ b/Neos.Neos/Classes/Controller/Service/NodesController.php @@ -29,6 +29,7 @@ use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateIds; +use Neos\Neos\Domain\Service\NodeTypeNameFactory; use Neos\Neos\FrontendRouting\NodeAddressFactory; use Neos\ContentRepository\Core\NodeType\NodeTypeConstraintParser; use Neos\ContentRepository\Core\Projection\ContentGraph\NodeTypeConstraints; @@ -114,7 +115,7 @@ public function indexAction( array|string $nodeIds = [], string $workspaceName = 'live', array $dimensions = [], - array $nodeTypes = ['Neos.Neos:Document'], + array $nodeTypes = [NodeTypeNameFactory::NAME_DOCUMENT], string $contextNode = null, array|string $nodeIdentifiers = [] ): void { @@ -435,7 +436,7 @@ protected function adoptNodeAndParents( )->block(); if ($copyContent === true) { - $contentNodeConstraint = NodeTypeConstraints::fromFilterString('!Neos.Neos:Document'); + $contentNodeConstraint = NodeTypeConstraints::fromFilterString('!' . NodeTypeNameFactory::NAME_DOCUMENT); $this->createNodeVariantsForChildNodes( $contentStreamId, $identifier, diff --git a/Neos.Neos/Classes/Domain/Service/NodeTypeNameFactory.php b/Neos.Neos/Classes/Domain/Service/NodeTypeNameFactory.php index b1f8caadb0f..0b44d46f688 100644 --- a/Neos.Neos/Classes/Domain/Service/NodeTypeNameFactory.php +++ b/Neos.Neos/Classes/Domain/Service/NodeTypeNameFactory.php @@ -20,34 +20,40 @@ #[Flow\Proxy(false)] final class NodeTypeNameFactory { + public const NAME_CONTENT_COLLECTION = 'Neos.Neos:ContentCollection'; public const NAME_DOCUMENT = 'Neos.Neos:Document'; + public const NAME_FALLBACK = 'Neos.Neos:FallbackNode'; + public const NAME_SHORTCUT = 'Neos.Neos:Shortcut'; public const NAME_SITE = 'Neos.Neos:Site'; public const NAME_SITES = 'Neos.Neos:Sites'; - public const NAME_CONTENT_COLLECTION = 'Neos.Neos:ContentCollection'; - public const NAME_FALLBACK = 'Neos.Neos:FallbackNode'; + + public static function forContentCollection(): NodeTypeName + { + return NodeTypeName::fromString(self::NAME_CONTENT_COLLECTION); + } public static function forDocument(): NodeTypeName { return NodeTypeName::fromString(self::NAME_DOCUMENT); } - public static function forSite(): NodeTypeName + public static function forFallback(): NodeTypeName { - return NodeTypeName::fromString(self::NAME_SITE); + return NodeTypeName::fromString(self::NAME_FALLBACK); } - public static function forSites(): NodeTypeName + public static function forShortcut(): NodeTypeName { - return NodeTypeName::fromString(self::NAME_SITES); + return NodeTypeName::fromString(self::NAME_SHORTCUT); } - public static function forContentCollection(): NodeTypeName + public static function forSite(): NodeTypeName { - return NodeTypeName::fromString(self::NAME_CONTENT_COLLECTION); + return NodeTypeName::fromString(self::NAME_SITE); } - public static function forFallback(): NodeTypeName + public static function forSites(): NodeTypeName { - return NodeTypeName::fromString(self::NAME_FALLBACK); + return NodeTypeName::fromString(self::NAME_SITES); } } diff --git a/Neos.Neos/Classes/Domain/Service/SiteNodeUtility.php b/Neos.Neos/Classes/Domain/Service/SiteNodeUtility.php index d68a8ae48b2..a8101261e60 100644 --- a/Neos.Neos/Classes/Domain/Service/SiteNodeUtility.php +++ b/Neos.Neos/Classes/Domain/Service/SiteNodeUtility.php @@ -46,7 +46,7 @@ public function findSiteNode(Node $node): Node $previousNode = null; $subgraph = $this->contentRepositoryRegistry->subgraphForNode($node); do { - if ($this->getNodeType($node)->isOfType('Neos.Neos:Sites')) { + if ($this->getNodeType($node)->isOfType(NodeTypeNameFactory::NAME_SITES)) { // the Site node is the one level underneath the "Sites" node. if (is_null($previousNode)) { break; @@ -82,7 +82,7 @@ public function findCurrentSiteNode( $rootNodeAggregate = $contentRepository->getContentGraph() ->findRootNodeAggregateByType( $contentStreamId, - NodeTypeName::fromString('Neos.Neos:Sites') + NodeTypeNameFactory::forSites() ); $sitesNode = $subgraph->findNodeById($rootNodeAggregate->nodeAggregateId); if ($sitesNode) { diff --git a/Neos.Neos/Classes/Domain/Service/SiteServiceInternals.php b/Neos.Neos/Classes/Domain/Service/SiteServiceInternals.php index 5e108410766..7ddcdeb26dd 100644 --- a/Neos.Neos/Classes/Domain/Service/SiteServiceInternals.php +++ b/Neos.Neos/Classes/Domain/Service/SiteServiceInternals.php @@ -69,7 +69,7 @@ public function removeSiteNode(SiteNodeName $siteNodeName): void foreach ($this->contentRepository->getContentStreamFinder()->findAllIds() as $contentStreamId) { $sitesNodeAggregate = $contentGraph->findRootNodeAggregateByType( $contentStreamId, - NodeTypeName::fromString('Neos.Neos:Sites') + NodeTypeNameFactory::forSites() ); $siteNodeAggregates = $contentGraph->findChildNodeAggregatesByName( $contentStreamId, diff --git a/Neos.Neos/Classes/FrontendRouting/Projection/DocumentUriPathProjection.php b/Neos.Neos/Classes/FrontendRouting/Projection/DocumentUriPathProjection.php index f2150759fde..193d349526e 100644 --- a/Neos.Neos/Classes/FrontendRouting/Projection/DocumentUriPathProjection.php +++ b/Neos.Neos/Classes/FrontendRouting/Projection/DocumentUriPathProjection.php @@ -41,6 +41,7 @@ use Neos\EventStore\Model\EventEnvelope; use Neos\EventStore\Model\EventStore\SetupResult; use Neos\Neos\Domain\Model\SiteNodeName; +use Neos\Neos\Domain\Service\NodeTypeNameFactory; use Neos\Neos\FrontendRouting\Exception\NodeNotFoundException; /** @@ -704,7 +705,7 @@ private function isDocumentNodeType(NodeTypeName $nodeTypeName): bool // HACK: We consider the currently configured node type of the given node. // This is a deliberate side effect of this projector! $nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName); - return $nodeType->isOfType('Neos.Neos:Document'); + return $nodeType->isOfType(NodeTypeNameFactory::NAME_DOCUMENT); } private function isShortcutNodeType(NodeTypeName $nodeTypeName): bool @@ -712,7 +713,7 @@ private function isShortcutNodeType(NodeTypeName $nodeTypeName): bool // HACK: We consider the currently configured node type of the given node. // This is a deliberate side effect of this projector! $nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName); - return $nodeType->isOfType('Neos.Neos:Shortcut'); + return $nodeType->isOfType(NodeTypeNameFactory::NAME_SHORTCUT); } private function tryGetNode(\Closure $closure): ?DocumentNodeInfo diff --git a/Neos.Neos/Classes/Fusion/MenuItemsImplementation.php b/Neos.Neos/Classes/Fusion/MenuItemsImplementation.php index 57692489567..dfb9a4f51d4 100644 --- a/Neos.Neos/Classes/Fusion/MenuItemsImplementation.php +++ b/Neos.Neos/Classes/Fusion/MenuItemsImplementation.php @@ -22,6 +22,7 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\NodeTypeConstraintsWithSubNodeTypes; use Neos\ContentRepository\Core\Projection\ContentGraph\Subtree; use Neos\Fusion\Exception as FusionException; +use Neos\Neos\Domain\Service\NodeTypeNameFactory; /** * A Fusion Menu object @@ -86,7 +87,7 @@ public function getFilter() { $filter = $this->fusionValue('filter'); if ($filter === null) { - $filter = 'Neos.Neos:Document'; + $filter = NodeTypeNameFactory::NAME_DOCUMENT; } return $filter; @@ -266,7 +267,7 @@ function (Node $node) use ( $traversedHierarchy = []; $nodeTypeConstraintsWithSubNodeTypes = NodeTypeConstraintsWithSubNodeTypes::create( $this->getNodeTypeConstraints()->withAdditionalDisallowedNodeType( - NodeTypeName::fromString('Neos.Neos:Sites') + NodeTypeNameFactory::forSites() ), $contentRepository->getNodeTypeManager() ); diff --git a/Neos.Neos/Classes/Routing/Cache/RouteCacheFlusher.php b/Neos.Neos/Classes/Routing/Cache/RouteCacheFlusher.php index b950ec57998..8f440d742ba 100644 --- a/Neos.Neos/Classes/Routing/Cache/RouteCacheFlusher.php +++ b/Neos.Neos/Classes/Routing/Cache/RouteCacheFlusher.php @@ -19,6 +19,7 @@ use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Flow\Mvc\Routing\RouterCachingService; +use Neos\Neos\Domain\Service\NodeTypeNameFactory; use Neos\Neos\Utility\NodeTypeWithFallbackProvider; /** @@ -60,7 +61,7 @@ public function registerNodeChange(Node $node) if (in_array($identifier, $this->tagsToFlush)) { return; } - if (!$this->getNodeType($node)->isOfType('Neos.Neos:Document')) { + if (!$this->getNodeType($node)->isOfType(NodeTypeNameFactory::NAME_DOCUMENT)) { return; } $this->tagsToFlush[] = $identifier; diff --git a/Neos.Neos/Classes/View/FusionView.php b/Neos.Neos/Classes/View/FusionView.php index b90974fe759..1aa51b1d6bf 100644 --- a/Neos.Neos/Classes/View/FusionView.php +++ b/Neos.Neos/Classes/View/FusionView.php @@ -23,6 +23,7 @@ use Neos\Fusion\Core\Runtime; use Neos\Fusion\Exception\RuntimeException; use Neos\Neos\Domain\Service\FusionService; +use Neos\Neos\Domain\Service\NodeTypeNameFactory; use Neos\Neos\Domain\Service\SiteNodeUtility; use Neos\Neos\Exception; use Neos\Neos\Utility\NodeTypeWithFallbackProvider; @@ -179,7 +180,7 @@ public function getFusionPath() protected function getClosestDocumentNode(Node $node): ?Node { $subgraph = $this->contentRepositoryRegistry->subgraphForNode($node); - while ($node !== null && !$this->getNodeType($node)->isOfType('Neos.Neos:Document')) { + while ($node !== null && !$this->getNodeType($node)->isOfType(NodeTypeNameFactory::NAME_DOCUMENT)) { $node = $subgraph->findParentNode($node->nodeAggregateId); } diff --git a/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php b/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php index a587aeae43a..5ce8e88c962 100644 --- a/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php +++ b/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php @@ -18,6 +18,7 @@ use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper; +use Neos\Neos\Domain\Service\NodeTypeNameFactory; use Neos\Neos\Utility\NodeTypeWithFallbackProvider; /** @@ -53,7 +54,7 @@ public function render(): mixed $currentNode = $node; while ($currentNode instanceof Node) { - if ($this->getNodeType($currentNode)->isOfType('Neos.Neos:Document')) { + if ($this->getNodeType($currentNode)->isOfType(NodeTypeNameFactory::NAME_DOCUMENT)) { $documentNodes[] = $currentNode; } $currentNode = $subgraph->findParentNode($currentNode->nodeAggregateId); diff --git a/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php b/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php index 085a36e3575..8b508faa4de 100644 --- a/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php +++ b/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php @@ -18,6 +18,7 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\Projection\ContentGraph\NodePath; +use Neos\Neos\Domain\Service\NodeTypeNameFactory; use Neos\Neos\FrontendRouting\NodeAddress; use Neos\Neos\FrontendRouting\NodeAddressFactory; use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints; @@ -300,7 +301,7 @@ public function render(): string json_encode($subgraph, JSON_PARTIAL_OUTPUT_ON_ERROR) ), 1601372444)); } - if ($resolvedNode && $this->getNodeType($resolvedNode)->isOfType('Neos.Neos:Shortcut')) { + if ($resolvedNode && $this->getNodeType($resolvedNode)->isOfType(NodeTypeNameFactory::NAME_SHORTCUT)) { try { $shortcutNodeAddress = $this->nodeShortcutResolver->resolveShortcutTarget( $nodeAddress, From 4bde5aa50214f93416e23a7f28d2c52eda32c956 Mon Sep 17 00:00:00 2001 From: Bernhard Schmitt Date: Fri, 1 Sep 2023 16:40:03 +0200 Subject: [PATCH 03/26] Remove fallback handling from NodeTypeManager --- .../src/Domain/Repository/NodeFactory.php | 8 +++- .../src/Domain/Repository/NodeFactory.php | 11 +++-- .../CRBehavioralTestsSubjectProvider.php | 34 --------------- ...yStringNodeBasedNodeTypeManagerFactory.php | 7 +--- .../NodeTypeAdjustment_Dimensions.feature | 5 +-- .../NodeTypeAdjustment_NoDimensions.feature | 5 +-- .../UnknownNodeType.feature | 6 +-- .../Classes/NodeType/NodeTypeManager.php | 32 ++++---------- .../Unit/NodeType/NodeTypeManagerTest.php | 42 ++----------------- .../src/Adjustment/LoadNodeTypeTrait.php | 14 +------ .../DefaultNodeTypeManagerFactory.php | 11 +++-- .../Domain/Service/SiteServiceInternals.php | 10 +++-- .../Service/NodeTypeSchemaBuilderTest.php | 3 +- 13 files changed, 45 insertions(+), 143 deletions(-) diff --git a/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/NodeFactory.php b/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/NodeFactory.php index 7794a3879d5..3caeedfd5d1 100644 --- a/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/NodeFactory.php +++ b/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/NodeFactory.php @@ -57,13 +57,17 @@ public function __construct( /** * @param array $nodeRow Node Row from projection (_node table) - * @throws NodeTypeNotFoundException */ public function mapNodeRowToNode( array $nodeRow, DimensionSpacePoint $dimensionSpacePoint, VisibilityConstraints $visibilityConstraints ): Node { + try { + $nodeType = $this->nodeTypeManager->getNodeType($nodeRow['nodetypename']); + } catch (NodeTypeNotFoundException $exception) { + $nodeType = null; + } return new Node( ContentSubgraphIdentity::create( $this->contentRepositoryId, @@ -75,7 +79,7 @@ public function mapNodeRowToNode( OriginDimensionSpacePoint::fromJsonString($nodeRow['origindimensionspacepoint']), NodeAggregateClassification::from($nodeRow['classification']), NodeTypeName::fromString($nodeRow['nodetypename']), - $this->nodeTypeManager->getNodeType($nodeRow['nodetypename']), + $nodeType, $this->createPropertyCollectionFromJsonString($nodeRow['properties']), isset($nodeRow['name']) ? NodeName::fromString($nodeRow['name']) : null, Timestamps::create( diff --git a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/NodeFactory.php b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/NodeFactory.php index 42b5ae409f5..a754346b794 100644 --- a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/NodeFactory.php +++ b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/NodeFactory.php @@ -23,6 +23,7 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Subtree; use Neos\ContentRepository\Core\Projection\ContentGraph\Subtrees; use Neos\ContentRepository\Core\Projection\ContentGraph\Timestamps; +use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFoundException; use Neos\ContentRepository\Core\SharedModel\Node\ReferenceName; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; @@ -71,8 +72,12 @@ public function mapNodeRowToNode( ?DimensionSpacePoint $dimensionSpacePoint = null, ?ContentStreamId $contentStreamId = null ): Node { - $nodeType = $this->nodeTypeManager->getNodeType($nodeRow['nodetypename']); - $result = new Node( + try { + $nodeType = $this->nodeTypeManager->getNodeType($nodeRow['nodetypename']); + } catch (NodeTypeNotFoundException $exception) { + $nodeType = null; + } + return new Node( ContentSubgraphIdentity::create( $this->contentRepositoryId, $contentStreamId ?: ContentStreamId::fromString($nodeRow['contentstreamid']), @@ -97,8 +102,6 @@ public function mapNodeRowToNode( isset($nodeRow['originallastmodified']) ? self::parseDateTimeString($nodeRow['originallastmodified']) : null, ), ); - - return $result; } /** diff --git a/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/CRBehavioralTestsSubjectProvider.php b/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/CRBehavioralTestsSubjectProvider.php index 08e8b622a4f..bfcb0806fc9 100644 --- a/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/CRBehavioralTestsSubjectProvider.php +++ b/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/CRBehavioralTestsSubjectProvider.php @@ -74,16 +74,6 @@ public function usingTheFollowingContentDimensions(TableNode $contentDimensions) public function usingTheFollowingNodeTypes(PyStringNode $serializedNodeTypesConfiguration): void { GherkinPyStringNodeBasedNodeTypeManagerFactory::initializeWithPyStringNode($serializedNodeTypesConfiguration); - GherkinPyStringNodeBasedNodeTypeManagerFactory::$fallbackNodeTypeName = null; - } - - /** - * @Given /^using the following node types with fallback to "([^"]*)":$/ - */ - public function usingTheFollowingNodeTypesWithFallback(string $fallbackNodeTypeName, PyStringNode $serializedNodeTypesConfiguration): void - { - GherkinPyStringNodeBasedNodeTypeManagerFactory::initializeWithPyStringNode($serializedNodeTypesConfiguration); - GherkinPyStringNodeBasedNodeTypeManagerFactory::$fallbackNodeTypeName = $fallbackNodeTypeName; } /** @@ -136,30 +126,6 @@ public function iChangeTheNodeTypesInContentRepositoryTo( } } - /** - * @Given /^I change the node types in content repository "([^"]*)" with fallback "([^"]*)" to:$/ - */ - public function iChangeTheNodeTypesInContentRepositoryWithFallbackTo( - string $contentRepositoryId, - string $fallbackNodeTypeName, - PyStringNode $serializedNodeTypesConfiguration - ): void { - if (!array_key_exists($contentRepositoryId, $this->contentRepositories)) { - throw new \DomainException('undeclared content repository ' . $contentRepositoryId); - } else { - $contentRepository = $this->contentRepositories[$contentRepositoryId]; - GherkinPyStringNodeBasedNodeTypeManagerFactory::initializeWithPyStringNode( - $serializedNodeTypesConfiguration, - $fallbackNodeTypeName - ); - GherkinTableNodeBasedContentDimensionSourceFactory::$contentDimensionsToUse = $contentRepository->getContentDimensionSource(); - $this->contentRepositories[$contentRepositoryId] = $this->createContentRepository(ContentRepositoryId::fromString($contentRepositoryId)); - if ($this->currentContentRepository->id->value === $contentRepositoryId) { - $this->currentContentRepository = $this->contentRepositories[$contentRepositoryId]; - } - } - } - protected function setUpContentRepository(ContentRepositoryId $contentRepositoryId): ContentRepository { /** diff --git a/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/GherkinPyStringNodeBasedNodeTypeManagerFactory.php b/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/GherkinPyStringNodeBasedNodeTypeManagerFactory.php index cb97583cc43..aaa78d4816e 100644 --- a/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/GherkinPyStringNodeBasedNodeTypeManagerFactory.php +++ b/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/GherkinPyStringNodeBasedNodeTypeManagerFactory.php @@ -31,8 +31,6 @@ final class GherkinPyStringNodeBasedNodeTypeManagerFactory implements NodeTypeMa { public static ?NodeTypeManager $nodeTypesToUse = null; - public static ?string $fallbackNodeTypeName = null; - /** * @param array $options */ @@ -44,7 +42,7 @@ public function build(ContentRepositoryId $contentRepositoryId, array $options): return self::$nodeTypesToUse; } - public static function initializeWithPyStringNode(PyStringNode $nodeTypesToUse, ?string $fallbackNodeTypeName = null): void + public static function initializeWithPyStringNode(PyStringNode $nodeTypesToUse): void { self::$nodeTypesToUse = new NodeTypeManager( fn (): array => Yaml::parse($nodeTypesToUse->getRaw()), @@ -58,8 +56,7 @@ public function getLabel(Node $node): string } }; } - }, - $fallbackNodeTypeName + } ); } diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/EventSourced/Migration/NodeTypeAdjustment_Dimensions.feature b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/EventSourced/Migration/NodeTypeAdjustment_Dimensions.feature index 910e7134a67..3b433612102 100644 --- a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/EventSourced/Migration/NodeTypeAdjustment_Dimensions.feature +++ b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/EventSourced/Migration/NodeTypeAdjustment_Dimensions.feature @@ -50,11 +50,8 @@ Feature: Adjust node types with a node migration # Actual Test ######################## # we remove the Document node type (which still exists in the CR) - When I change the node types in content repository "default" with fallback "Neos.ContentRepository:Fallback" to: + When I change the node types in content repository "default" to: """yaml - # !!fallback node is needed!! - TODO DISCUSS - 'Neos.ContentRepository:Fallback': [] - 'Neos.ContentRepository:Root': constraints: nodeTypes: diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/EventSourced/Migration/NodeTypeAdjustment_NoDimensions.feature b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/EventSourced/Migration/NodeTypeAdjustment_NoDimensions.feature index d5d84d3b0d9..511099385b9 100644 --- a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/EventSourced/Migration/NodeTypeAdjustment_NoDimensions.feature +++ b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/EventSourced/Migration/NodeTypeAdjustment_NoDimensions.feature @@ -48,11 +48,8 @@ Feature: Adjust node types with a node migration # Actual Test ######################## # we remove the Document node type (which still exists in the CR) - And I change the node types in content repository "default" with fallback "Neos.ContentRepository:Fallback" to: + And I change the node types in content repository "default" to: """yaml - # !!fallback node is needed!! - TODO DISCUSS - 'Neos.ContentRepository:Fallback': [] - 'Neos.ContentRepository:Root': constraints: nodeTypes: diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/StructureAdjustment/UnknownNodeType.feature b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/StructureAdjustment/UnknownNodeType.feature index 8122ebecf33..428038ea425 100644 --- a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/StructureAdjustment/UnknownNodeType.feature +++ b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/StructureAdjustment/UnknownNodeType.feature @@ -5,11 +5,10 @@ Feature: Unknown node types Background: Given using no content dimensions - And using the following node types with fallback to "Neos.ContentRepository:Fallback": + And using the following node types: """yaml 'Neos.ContentRepository:Root': [] 'Neos.ContentRepository.Testing:Document': [] - 'Neos.ContentRepository:Fallback': [] """ And using identifier "default", I define a content repository And I am in content repository "default" @@ -40,10 +39,9 @@ Feature: Unknown node types Then I expect no needed structure adjustments for type "Neos.ContentRepository.Testing:Document" Scenario: When removing "Neos.ContentRepository.Testing:Document", we find a missing node type. - Given I change the node types in content repository "default" with fallback "Neos.ContentRepository:Fallback" to: + Given I change the node types in content repository "default" to: """yaml 'Neos.ContentRepository:Root': [] - 'Neos.ContentRepository:Fallback': [] """ Then I expect the following structure adjustments for type "Neos.ContentRepository.Testing:Document": | Type | nodeAggregateId | diff --git a/Neos.ContentRepository.Core/Classes/NodeType/NodeTypeManager.php b/Neos.ContentRepository.Core/Classes/NodeType/NodeTypeManager.php index a2f2be011a8..9fa0f00408b 100644 --- a/Neos.ContentRepository.Core/Classes/NodeType/NodeTypeManager.php +++ b/Neos.ContentRepository.Core/Classes/NodeType/NodeTypeManager.php @@ -40,8 +40,7 @@ class NodeTypeManager public function __construct( private readonly \Closure $nodeTypeConfigLoader, - private readonly NodeLabelGeneratorFactoryInterface $nodeLabelGeneratorFactory, - private readonly ?string $fallbackNodeTypeName + private readonly NodeLabelGeneratorFactoryInterface $nodeLabelGeneratorFactory ) { } @@ -120,28 +119,13 @@ public function getNodeType(string|NodeTypeName $nodeTypeName): NodeType return $this->cachedNodeTypes[$nodeTypeName]; } - if ($this->fallbackNodeTypeName === null) { - throw new NodeTypeNotFoundException( - sprintf( - 'The node type "%s" is not available and no fallback NodeType is configured.', - $nodeTypeName - ), - 1316598370 - ); - } - - if (!$this->hasNodeType($this->fallbackNodeTypeName)) { - throw new NodeTypeNotFoundException( - sprintf( - 'The node type "%s" is not available and the configured fallback NodeType "%s" is not available.', - $nodeTypeName, - $this->fallbackNodeTypeName - ), - 1438166322 - ); - } - - return $this->getNodeType($this->fallbackNodeTypeName); + throw new NodeTypeNotFoundException( + sprintf( + 'The node type "%s" is not available', + $nodeTypeName + ), + 1316598370 + ); } /** diff --git a/Neos.ContentRepository.Core/Tests/Unit/NodeType/NodeTypeManagerTest.php b/Neos.ContentRepository.Core/Tests/Unit/NodeType/NodeTypeManagerTest.php index 0dc9812c21c..60dfb8741bd 100644 --- a/Neos.ContentRepository.Core/Tests/Unit/NodeType/NodeTypeManagerTest.php +++ b/Neos.ContentRepository.Core/Tests/Unit/NodeType/NodeTypeManagerTest.php @@ -38,12 +38,11 @@ public function setUp(): void * * @param array $nodeTypesFixtureData */ - protected function prepareNodeTypeManager(array $nodeTypesFixtureData, string $fallbackNodeTypeName = '') + protected function prepareNodeTypeManager(array $nodeTypesFixtureData) { $this->nodeTypeManager = new NodeTypeManager( fn() => $nodeTypesFixtureData, - new DefaultNodeLabelGeneratorFactory(), - $fallbackNodeTypeName + new DefaultNodeLabelGeneratorFactory() ); } @@ -133,8 +132,7 @@ protected function prepareNodeTypeManager(array $nodeTypesFixtureData, string $f 'Neos.ContentRepository.Testing:Page2' => false, 'Neos.ContentRepository.Testing:Page3' => null ] - ], - 'Neos.ContentRepository:FallbackNode' => [] + ] ]; /** @@ -173,37 +171,6 @@ public function getNodeTypeThrowsExceptionForUnknownNodeType() $this->nodeTypeManager->getNodeType('Neos.ContentRepository.Testing:TextFooBarNotHere'); } - /** - * @test - */ - public function getNodeTypeThrowsExceptionIfNoFallbackNodeTypeIsConfigured() - { - $this->expectException(NodeTypeNotFoundException::class); - $this->nodeTypeManager->getNodeType('Neos.ContentRepository.Testing:TextFooBarNotHere'); - } - - /** - * @test - */ - public function getNodeTypeThrowsExceptionIfConfiguredFallbackNodeTypeCantBeFound() - { - $this->expectException(NodeTypeNotFoundException::class); - $this->prepareNodeTypeManager($this->nodeTypesFixture, 'Neos.ContentRepository:NonExistingFallbackNode'); - $this->nodeTypeManager->getNodeType('Neos.ContentRepository.Testing:TextFooBarNotHere'); - } - - /** - * @test - */ - public function getNodeTypeReturnsFallbackNodeTypeIfConfigured() - { - $this->prepareNodeTypeManager($this->nodeTypesFixture, 'Neos.ContentRepository:FallbackNode'); - - $expectedNodeType = $this->nodeTypeManager->getNodeType('Neos.ContentRepository:FallbackNode'); - $fallbackNodeType = $this->nodeTypeManager->getNodeType('Neos.ContentRepository.Testing:TextFooBarNotHere'); - self::assertSame($expectedNodeType, $fallbackNodeType); - } - /** * @test */ @@ -243,8 +210,7 @@ public function getNodeTypesReturnsRegisteredNodeTypes() 'Neos.ContentRepository.Testing:Page', 'Neos.ContentRepository.Testing:Page2', 'Neos.ContentRepository.Testing:Page3', - 'Neos.ContentRepository.Testing:DocumentWithSupertypes', - 'Neos.ContentRepository:FallbackNode' + 'Neos.ContentRepository.Testing:DocumentWithSupertypes' ]; self::assertEquals($expectedNodeTypes, array_keys($this->nodeTypeManager->getNodeTypes())); } diff --git a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/LoadNodeTypeTrait.php b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/LoadNodeTypeTrait.php index 2728d52caad..d6f12df889e 100644 --- a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/LoadNodeTypeTrait.php +++ b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/LoadNodeTypeTrait.php @@ -14,24 +14,14 @@ trait LoadNodeTypeTrait abstract protected function getNodeTypeManager(): NodeTypeManager; /** - * loads and returns the node type, but only if it is not the FallbackNodeType - * - * @param NodeTypeName $nodeTypeName - * @return NodeType|null + * loads and returns the node type or null if it does not exist */ protected function loadNodeType(NodeTypeName $nodeTypeName): ?NodeType { try { - $nodeType = $this->getNodeTypeManager()->getNodeType($nodeTypeName->value); - if (!$nodeTypeName->equals($nodeType->name)) { - // the $nodeTypeName was different than the fetched node type; so that means - // that the FallbackNodeType has been returned. - return null; - } - return $nodeType; + return $this->getNodeTypeManager()->getNodeType($nodeTypeName); } catch (NodeTypeNotFoundException $e) { // the $nodeTypeName was not found; so we need to remove all nodes of this type. - // This case applies if the fallbackNodeType is not configured. return null; } } diff --git a/Neos.ContentRepositoryRegistry/Classes/Factory/NodeTypeManager/DefaultNodeTypeManagerFactory.php b/Neos.ContentRepositoryRegistry/Classes/Factory/NodeTypeManager/DefaultNodeTypeManagerFactory.php index 2e587e187e6..3eb010d5c10 100644 --- a/Neos.ContentRepositoryRegistry/Classes/Factory/NodeTypeManager/DefaultNodeTypeManagerFactory.php +++ b/Neos.ContentRepositoryRegistry/Classes/Factory/NodeTypeManager/DefaultNodeTypeManagerFactory.php @@ -7,12 +7,12 @@ use Neos\ContentRepositoryRegistry\Configuration\NodeTypeEnrichmentService; use Neos\Flow\Configuration\ConfigurationManager; -class DefaultNodeTypeManagerFactory implements NodeTypeManagerFactoryInterface +readonly class DefaultNodeTypeManagerFactory implements NodeTypeManagerFactoryInterface { public function __construct( - private readonly ConfigurationManager $configurationManager, - private readonly ObjectManagerBasedNodeLabelGeneratorFactory $nodeLabelGeneratorFactory, - private readonly NodeTypeEnrichmentService $nodeTypeEnrichmentService, + private ConfigurationManager $configurationManager, + private ObjectManagerBasedNodeLabelGeneratorFactory $nodeLabelGeneratorFactory, + private NodeTypeEnrichmentService $nodeTypeEnrichmentService, ) { } @@ -24,8 +24,7 @@ function () { $configuration = $this->configurationManager->getConfiguration('NodeTypes'); return $this->nodeTypeEnrichmentService->enrichNodeTypeLabelsConfiguration($configuration); }, - $this->nodeLabelGeneratorFactory, - $options['fallbackNodeTypeName'] ?? null, + $this->nodeLabelGeneratorFactory ); } } diff --git a/Neos.Neos/Classes/Domain/Service/SiteServiceInternals.php b/Neos.Neos/Classes/Domain/Service/SiteServiceInternals.php index 7ddcdeb26dd..15e8a2cd8c4 100644 --- a/Neos.Neos/Classes/Domain/Service/SiteServiceInternals.php +++ b/Neos.Neos/Classes/Domain/Service/SiteServiceInternals.php @@ -97,14 +97,16 @@ public function createSiteNodeIfNotExists(Site $site, string $nodeTypeName): voi $liveContentStreamId, NodeTypeNameFactory::forSites() ); - $siteNodeType = $this->nodeTypeManager->getNodeType($nodeTypeName); - - if ($siteNodeType->name === NodeTypeNameFactory::forFallback()) { + try { + $this->nodeTypeManager->getNodeType($nodeTypeName); + } catch (NodeTypeNotFoundException $exception) { throw new NodeTypeNotFoundException( 'Cannot create a site using a non-existing node type.', - 1412372375 + 1412372375, + $exception ); } + $siteNodeAggregate = $this->contentRepository->getContentGraph()->findChildNodeAggregatesByName( $liveContentStreamId, $sitesNodeIdentifier, diff --git a/Neos.Neos/Tests/Functional/Service/NodeTypeSchemaBuilderTest.php b/Neos.Neos/Tests/Functional/Service/NodeTypeSchemaBuilderTest.php index f0d8d3d6ac1..f5c64ffef50 100644 --- a/Neos.Neos/Tests/Functional/Service/NodeTypeSchemaBuilderTest.php +++ b/Neos.Neos/Tests/Functional/Service/NodeTypeSchemaBuilderTest.php @@ -42,8 +42,7 @@ public function setUp(): void $this->nodeTypeSchemaBuilder = NodeTypeSchemaBuilder::create( new NodeTypeManager( fn() => $configurationManager->getConfiguration('NodeTypes'), - $nodeLabelGeneratorFactory, - null + $nodeLabelGeneratorFactory ) ); $this->schema = $this->nodeTypeSchemaBuilder->generateNodeTypeSchema(); From a864ced0eb0fd94e35a252efc9bdf923b021652f Mon Sep 17 00:00:00 2001 From: Bernhard Schmitt Date: Fri, 1 Sep 2023 16:52:51 +0200 Subject: [PATCH 04/26] Pacify linter --- .composer.json | 2 +- .../Classes/Projection/ContentGraph/Node.php | 2 +- composer.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.composer.json b/.composer.json index 85936d7be80..ac62d034ded 100644 --- a/.composer.json +++ b/.composer.json @@ -14,7 +14,7 @@ "scripts": { "lint:phpcs-psr12": "../../bin/phpcs --colors --standard=PSR12 ./Neos.ContentGraph.DoctrineDbalAdapter/src ./Neos.ContentGraph.PostgreSQLAdapter/src ./Neos.ContentRepository.BehavioralTests/Classes ./Neos.ContentRepository.TestSuite/Classes ./Neos.ContentRepository.Core/Classes ./Neos.Neos/Classes", "lint:phpcs": [ - "@lint:phpcs-psr12 --exclude=Generic.Files.LineLength" + "@lint:phpcs-psr12 --exclude=Generic.Files.LineLength,PSR1.Files.SideEffects" ], "lint:phpstan": "../../bin/phpstan analyse", "lint": [ diff --git a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php index 50934dc01f8..adc0ca962a2 100644 --- a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php +++ b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php @@ -115,7 +115,7 @@ public function hasProperty(string $propertyName): bool */ public function getLabel(): string { - return $this->nodeType->getNodeLabelGenerator()->getLabel($this); + return $this->nodeType?->getNodeLabelGenerator()->getLabel($this) ?: $this->nodeTypeName->value; } public function equals(Node $other): bool diff --git a/composer.json b/composer.json index 1232b88a851..230eb38b459 100644 --- a/composer.json +++ b/composer.json @@ -89,7 +89,7 @@ "scripts": { "lint:phpcs-psr12": "../../bin/phpcs --colors --standard=PSR12 ./Neos.ContentGraph.DoctrineDbalAdapter/src ./Neos.ContentGraph.PostgreSQLAdapter/src ./Neos.ContentRepository.BehavioralTests/Classes ./Neos.ContentRepository.TestSuite/Classes ./Neos.ContentRepository.Core/Classes ./Neos.Neos/Classes", "lint:phpcs": [ - "@lint:phpcs-psr12 --exclude=Generic.Files.LineLength" + "@lint:phpcs-psr12 --exclude=Generic.Files.LineLength,PSR1.Files.SideEffects" ], "lint:phpstan": "../../bin/phpstan analyse", "lint": [ From 9d3efb32829675c83804771fd193208016fcd655 Mon Sep 17 00:00:00 2001 From: Bernhard Schmitt Date: Fri, 1 Sep 2023 17:12:06 +0200 Subject: [PATCH 05/26] Move ContentRepositoryRegistry injection to NodeTypeWithFallbackProvider --- .../Privilege/Node/NodePrivilegeContext.php | 7 ------- .../Classes/Controller/Backend/ContentController.php | 8 -------- Neos.Neos/Classes/Controller/Frontend/NodeController.php | 9 --------- .../Module/Management/WorkspacesController.php | 8 -------- .../Classes/Domain/Service/NodeSiteResolvingService.php | 8 -------- Neos.Neos/Classes/Domain/Service/SiteNodeUtility.php | 4 ---- .../Integrations/ContentRepositoryIntegrationService.php | 4 ---- Neos.Neos/Classes/Fusion/Helper/NodeHelper.php | 7 ------- Neos.Neos/Classes/Fusion/Helper/NodeLabelToken.php | 7 ------- Neos.Neos/Classes/Routing/Cache/RouteCacheFlusher.php | 7 ------- .../Classes/Utility/NodeTypeWithFallbackProvider.php | 7 +++---- Neos.Neos/Classes/View/FusionView.php | 7 ------- .../Backend/DocumentBreadcrumbPathViewHelper.php | 7 ------- Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php | 7 ------- 14 files changed, 3 insertions(+), 94 deletions(-) diff --git a/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php b/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php index 7a8c370ebf7..087e0a2c56b 100644 --- a/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php +++ b/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php @@ -17,7 +17,6 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindAncestorNodesFilter; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; -use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Flow\Security\Context as SecurityContext; use Neos\Neos\Utility\NodeTypeWithFallbackProvider; @@ -35,12 +34,6 @@ class NodePrivilegeContext */ protected $securityContext; - /** - * @Flow\Inject - * @var ContentRepositoryRegistry - */ - protected $contentRepositoryRegistry; - protected Node $node; protected ?ContentSubgraphInterface $subgraph; diff --git a/Neos.Neos/Classes/Controller/Backend/ContentController.php b/Neos.Neos/Classes/Controller/Backend/ContentController.php index a0c24e8c7aa..ebfcd27ccf9 100644 --- a/Neos.Neos/Classes/Controller/Backend/ContentController.php +++ b/Neos.Neos/Classes/Controller/Backend/ContentController.php @@ -14,16 +14,11 @@ namespace Neos\Neos\Controller\Backend; -use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; -use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\Neos\Domain\Service\NodeTypeNameFactory; use Neos\Neos\FrontendRouting\NodeAddressFactory; use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints; -use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; -use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; -use Neos\Flow\I18n\EelHelper\TranslationHelper; use Neos\Flow\Mvc\Controller\ActionController; use Neos\Flow\Mvc\Exception\NoSuchArgumentException; use Neos\Flow\Persistence\Exception\IllegalObjectTypeException; @@ -106,9 +101,6 @@ class ContentController extends ActionController */ protected $propertyMapper; - #[Flow\Inject] - protected ContentRepositoryRegistry $contentRepositoryRegistry; - /** * Initialize property mapping as the upload usually comes from the Inspector JavaScript * @throws NoSuchArgumentException diff --git a/Neos.Neos/Classes/Controller/Frontend/NodeController.php b/Neos.Neos/Classes/Controller/Frontend/NodeController.php index cc477ca9f47..163159078d9 100644 --- a/Neos.Neos/Classes/Controller/Frontend/NodeController.php +++ b/Neos.Neos/Classes/Controller/Frontend/NodeController.php @@ -15,18 +15,15 @@ namespace Neos\Neos\Controller\Frontend; use Neos\ContentRepository\Core\ContentRepository; -use Neos\ContentRepository\Core\Projection\ContentGraph\AbsoluteNodePath; use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphWithRuntimeCaches\ContentSubgraphWithRuntimeCaches; use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphWithRuntimeCaches\InMemoryCache; use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindSubtreeFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; -use Neos\ContentRepository\Core\Projection\ContentGraph\NodePath; use Neos\ContentRepository\Core\Projection\ContentGraph\Nodes; use Neos\ContentRepository\Core\Projection\ContentGraph\Subtree; use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; -use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Flow\Mvc\Controller\ActionController; use Neos\Flow\Mvc\Exception\NoMatchingRouteException; @@ -54,12 +51,6 @@ class NodeController extends ActionController { use NodeTypeWithFallbackProvider; - /** - * @Flow\Inject - * @var ContentRepositoryRegistry - */ - protected $contentRepositoryRegistry; - /** * @Flow\Inject * @var PrivilegeManagerInterface diff --git a/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php b/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php index 24d720131a3..b24d2947fe2 100644 --- a/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php +++ b/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php @@ -19,7 +19,6 @@ use Neos\ContentRepository\Core\Feature\WorkspacePublication\Dto\NodeIdToPublishOrDiscard; use Neos\ContentRepository\Core\Feature\WorkspaceCreation\Exception\WorkspaceAlreadyExists; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindAncestorNodesFilter; -use Neos\ContentRepository\Core\Projection\ContentGraph\NodeTypeConstraints; use Neos\ContentRepository\Core\SharedModel\Node\NodeName; use Neos\Flow\I18n\Exception\IndexOutOfBoundsException; use Neos\Flow\I18n\Exception\InvalidFormatPlaceholderException; @@ -45,7 +44,6 @@ use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceDescription; use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceTitle; -use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Diff\Diff; use Neos\Diff\Renderer\Html\HtmlArrayRenderer; use Neos\Neos\Controller\Module\ModuleTranslationTrait; @@ -105,12 +103,6 @@ class WorkspacesController extends AbstractModuleController */ protected $packageManager; - /** - * @var ContentRepositoryRegistry - * @Flow\Inject - */ - protected $contentRepositoryRegistry; - /** * Display a list of unpublished content * diff --git a/Neos.Neos/Classes/Domain/Service/NodeSiteResolvingService.php b/Neos.Neos/Classes/Domain/Service/NodeSiteResolvingService.php index 2d66165c41d..dde5b72b0b0 100644 --- a/Neos.Neos/Classes/Domain/Service/NodeSiteResolvingService.php +++ b/Neos.Neos/Classes/Domain/Service/NodeSiteResolvingService.php @@ -15,11 +15,9 @@ namespace Neos\Neos\Domain\Service; use Neos\ContentRepository\Core\Factory\ContentRepositoryId; -use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphIdentity; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\Neos\FrontendRouting\NodeAddress; use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints; -use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Neos\Utility\NodeTypeWithFallbackProvider; @@ -28,12 +26,6 @@ class NodeSiteResolvingService { use NodeTypeWithFallbackProvider; - /** - * @Flow\Inject - * @var ContentRepositoryRegistry - */ - protected $contentRepositoryRegistry; - public function findSiteNodeForNodeAddress( NodeAddress $nodeAddress, ContentRepositoryId $contentRepositoryId diff --git a/Neos.Neos/Classes/Domain/Service/SiteNodeUtility.php b/Neos.Neos/Classes/Domain/Service/SiteNodeUtility.php index a8101261e60..819159756aa 100644 --- a/Neos.Neos/Classes/Domain/Service/SiteNodeUtility.php +++ b/Neos.Neos/Classes/Domain/Service/SiteNodeUtility.php @@ -18,10 +18,8 @@ use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; use Neos\ContentRepository\Core\Factory\ContentRepositoryId; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; -use Neos\ContentRepository\Core\NodeType\NodeTypeName; use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; -use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Neos\Domain\Model\Site; use Neos\Neos\Domain\Repository\DomainRepository; @@ -34,11 +32,9 @@ final class SiteNodeUtility use NodeTypeWithFallbackProvider; public function __construct( - ContentRepositoryRegistry $contentRepositoryRegistry, private readonly DomainRepository $domainRepository, private readonly SiteRepository $siteRepository ) { - $this->contentRepositoryRegistry = $contentRepositoryRegistry; } public function findSiteNode(Node $node): Node diff --git a/Neos.Neos/Classes/EventLog/Integrations/ContentRepositoryIntegrationService.php b/Neos.Neos/Classes/EventLog/Integrations/ContentRepositoryIntegrationService.php index 17889f30647..83542e206af 100644 --- a/Neos.Neos/Classes/EventLog/Integrations/ContentRepositoryIntegrationService.php +++ b/Neos.Neos/Classes/EventLog/Integrations/ContentRepositoryIntegrationService.php @@ -18,7 +18,6 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\Projection\Workspace\Workspace; use Neos\Neos\FrontendRouting\NodeAddressFactory; -use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Flow\Persistence\PersistenceManagerInterface; use Neos\Neos\Utility\NodeTypeWithFallbackProvider; @@ -54,9 +53,6 @@ class ContentRepositoryIntegrationService extends AbstractIntegrationService */ protected $persistenceManager; - #[Flow\Inject] - protected ContentRepositoryRegistry $contentRepositoryRegistry; - /** * @var array */ diff --git a/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php b/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php index 40df534afe2..3c91c83ff3b 100644 --- a/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php +++ b/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php @@ -21,7 +21,6 @@ use Neos\Neos\Domain\Service\NodeTypeNameFactory; use Neos\Neos\FrontendRouting\NodeAddressFactory; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; -use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Eel\ProtectedContextAwareInterface; use Neos\Neos\Domain\Exception; @@ -35,12 +34,6 @@ class NodeHelper implements ProtectedContextAwareInterface { use NodeTypeWithFallbackProvider; - /** - * @Flow\Inject - * @var ContentRepositoryRegistry - */ - protected $contentRepositoryRegistry; - /** * Check if the given node is already a collection, find collection by nodePath otherwise, throw exception * if no content collection could be found diff --git a/Neos.Neos/Classes/Fusion/Helper/NodeLabelToken.php b/Neos.Neos/Classes/Fusion/Helper/NodeLabelToken.php index 6b2ad6a57c5..485fb42f194 100644 --- a/Neos.Neos/Classes/Fusion/Helper/NodeLabelToken.php +++ b/Neos.Neos/Classes/Fusion/Helper/NodeLabelToken.php @@ -15,7 +15,6 @@ namespace Neos\Neos\Fusion\Helper; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; -use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Eel\Helper\StringHelper; use Neos\Eel\ProtectedContextAwareInterface; use Neos\Flow\Annotations as Flow; @@ -42,12 +41,6 @@ class NodeLabelToken implements ProtectedContextAwareInterface */ protected $stringHelper; - /** - * @Flow\Inject - * @var ContentRepositoryRegistry - */ - protected $contentRepositoryRegistry; - /** * @var string */ diff --git a/Neos.Neos/Classes/Routing/Cache/RouteCacheFlusher.php b/Neos.Neos/Classes/Routing/Cache/RouteCacheFlusher.php index 8f440d742ba..0d7e02fecde 100644 --- a/Neos.Neos/Classes/Routing/Cache/RouteCacheFlusher.php +++ b/Neos.Neos/Classes/Routing/Cache/RouteCacheFlusher.php @@ -16,7 +16,6 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\Projection\Workspace\Workspace; -use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Flow\Mvc\Routing\RouterCachingService; use Neos\Neos\Domain\Service\NodeTypeNameFactory; @@ -37,12 +36,6 @@ class RouteCacheFlusher */ protected $routeCachingService; - /** - * @Flow\Inject - * @var ContentRepositoryRegistry - */ - protected $contentRepositoryRegistry; - /** * @var array */ diff --git a/Neos.Neos/Classes/Utility/NodeTypeWithFallbackProvider.php b/Neos.Neos/Classes/Utility/NodeTypeWithFallbackProvider.php index 9ad90f1363f..43dbf60129a 100644 --- a/Neos.Neos/Classes/Utility/NodeTypeWithFallbackProvider.php +++ b/Neos.Neos/Classes/Utility/NodeTypeWithFallbackProvider.php @@ -6,6 +6,7 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\SharedModel\Exception\NodeTypeNotFoundException; use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; +use Neos\Flow\Annotations as Flow; use Neos\Neos\Domain\Service\NodeTypeNameFactory; /** @@ -13,10 +14,8 @@ */ trait NodeTypeWithFallbackProvider { - /** - * @var ContentRepositoryRegistry - */ - protected $contentRepositoryRegistry; + #[Flow\Inject] + protected ContentRepositoryRegistry $contentRepositoryRegistry; protected function getNodeType(Node $node): NodeType { diff --git a/Neos.Neos/Classes/View/FusionView.php b/Neos.Neos/Classes/View/FusionView.php index 1aa51b1d6bf..71e3c797207 100644 --- a/Neos.Neos/Classes/View/FusionView.php +++ b/Neos.Neos/Classes/View/FusionView.php @@ -16,7 +16,6 @@ use GuzzleHttp\Psr7\Message; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; -use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Flow\Mvc\View\AbstractView; use Neos\Flow\Security\Context; @@ -43,12 +42,6 @@ class FusionView extends AbstractView */ protected $siteNodeUtility; - /** - * @Flow\Inject - * @var ContentRepositoryRegistry - */ - protected $contentRepositoryRegistry; - /** * Renders the view * diff --git a/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php b/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php index 5ce8e88c962..1a6e90db3a9 100644 --- a/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php +++ b/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php @@ -15,7 +15,6 @@ namespace Neos\Neos\ViewHelpers\Backend; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; -use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper; use Neos\Neos\Domain\Service\NodeTypeNameFactory; @@ -33,12 +32,6 @@ class DocumentBreadcrumbPathViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * @Flow\Inject - * @var ContentRepositoryRegistry - */ - protected $contentRepositoryRegistry; - public function initializeArguments(): void { parent::initializeArguments(); diff --git a/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php b/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php index 8b508faa4de..619ca6b29b9 100644 --- a/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php +++ b/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php @@ -22,7 +22,6 @@ use Neos\Neos\FrontendRouting\NodeAddress; use Neos\Neos\FrontendRouting\NodeAddressFactory; use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints; -use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Flow\Http\Exception as HttpException; use Neos\Flow\Log\ThrowableStorageInterface; @@ -146,12 +145,6 @@ class NodeViewHelper extends AbstractTagBasedViewHelper */ protected $nodeShortcutResolver; - /** - * @Flow\Inject - * @var ContentRepositoryRegistry - */ - protected $contentRepositoryRegistry; - /** * @Flow\Inject * @var ThrowableStorageInterface From e25a33467297434c7ffaa973f8c3424db97ff46e Mon Sep 17 00:00:00 2001 From: Bernhard Schmitt Date: Fri, 1 Sep 2023 17:19:23 +0200 Subject: [PATCH 06/26] Provide content NodeTypeName in NodeTypeNameFactory --- Neos.Neos/Classes/Domain/Service/NodeTypeNameFactory.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Neos.Neos/Classes/Domain/Service/NodeTypeNameFactory.php b/Neos.Neos/Classes/Domain/Service/NodeTypeNameFactory.php index 0b44d46f688..6af5e3827b1 100644 --- a/Neos.Neos/Classes/Domain/Service/NodeTypeNameFactory.php +++ b/Neos.Neos/Classes/Domain/Service/NodeTypeNameFactory.php @@ -20,6 +20,7 @@ #[Flow\Proxy(false)] final class NodeTypeNameFactory { + public const NAME_CONTENT = 'Neos.Neos:Content'; public const NAME_CONTENT_COLLECTION = 'Neos.Neos:ContentCollection'; public const NAME_DOCUMENT = 'Neos.Neos:Document'; public const NAME_FALLBACK = 'Neos.Neos:FallbackNode'; @@ -27,6 +28,11 @@ final class NodeTypeNameFactory public const NAME_SITE = 'Neos.Neos:Site'; public const NAME_SITES = 'Neos.Neos:Sites'; + public static function forContent(): NodeTypeName + { + return NodeTypeName::fromString(self::NAME_CONTENT); + } + public static function forContentCollection(): NodeTypeName { return NodeTypeName::fromString(self::NAME_CONTENT_COLLECTION); From 87ceb38924c5c14510966ec7857e6b6caf55ef78 Mon Sep 17 00:00:00 2001 From: Bernhard Schmitt Date: Fri, 1 Sep 2023 17:43:17 +0200 Subject: [PATCH 07/26] Adjust NodeType mocking --- .../DefaultPropertyEditorPostprocessorTest.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Neos.Neos/Tests/Unit/NodeTypePostprocessor/DefaultPropertyEditorPostprocessorTest.php b/Neos.Neos/Tests/Unit/NodeTypePostprocessor/DefaultPropertyEditorPostprocessorTest.php index 7bffae66acd..b0c1d52fafa 100644 --- a/Neos.Neos/Tests/Unit/NodeTypePostprocessor/DefaultPropertyEditorPostprocessorTest.php +++ b/Neos.Neos/Tests/Unit/NodeTypePostprocessor/DefaultPropertyEditorPostprocessorTest.php @@ -1,6 +1,6 @@ inject($postprocessor, 'dataTypesDefaultConfiguration', $dataTypesDefaultConfiguration); $this->inject($postprocessor, 'editorDefaultConfiguration', $editorDefaultConfiguration); - $mockNodeType = $this->getMockBuilder(NodeType::class)->disableOriginalConstructor()->getMock(); - $mockNodeType->method('getName')->willReturn('Some.NodeType:Name'); + $mockNodeType = new NodeType( + NodeTypeName::fromString('Some.NodeType:Name'), + [], + [], + new NodeTypeManager( + fn () => [], + new DefaultNodeLabelGeneratorFactory() + ), + new DefaultNodeLabelGeneratorFactory() + ); $postprocessor->process($mockNodeType, $configuration, []); return $configuration; } From 852a2dcbe8c2618e826653dd20358981ee869ebd Mon Sep 17 00:00:00 2001 From: Bernhard Schmitt Date: Fri, 1 Sep 2023 18:02:43 +0200 Subject: [PATCH 08/26] Avoid node mocking in NodeHelperTest --- .../Functional/Fusion/NodeHelperTest.php | 70 ++++++++++--------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/Neos.Neos/Tests/Functional/Fusion/NodeHelperTest.php b/Neos.Neos/Tests/Functional/Fusion/NodeHelperTest.php index 2c6852d3679..2bb7433c6d5 100644 --- a/Neos.Neos/Tests/Functional/Fusion/NodeHelperTest.php +++ b/Neos.Neos/Tests/Functional/Fusion/NodeHelperTest.php @@ -13,9 +13,13 @@ use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; use Neos\ContentRepository\Core\Factory\ContentRepositoryId; +use Neos\ContentRepository\Core\Feature\NodeModification\Dto\SerializedPropertyValue; +use Neos\ContentRepository\Core\Feature\NodeModification\Dto\SerializedPropertyValues; +use Neos\ContentRepository\Core\NodeType\DefaultNodeLabelGeneratorFactory; +use Neos\ContentRepository\Core\NodeType\NodeTypeManager; use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphIdentity; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; -use Neos\ContentRepository\Core\Projection\ContentGraph\PropertyCollectionInterface; +use Neos\ContentRepository\Core\Projection\ContentGraph\PropertyCollection; use Neos\ContentRepository\Core\Projection\ContentGraph\Timestamps; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateClassification; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; @@ -24,6 +28,7 @@ use Neos\ContentRepository\Core\NodeType\NodeTypeName; use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; +use Neos\ContentRepository\TestSuite\Unit\NodeSubjectProvider; use Neos\Fusion\Tests\Functional\FusionObjects\AbstractFusionObjectTest; use PHPUnit\Framework\MockObject\MockObject; @@ -117,37 +122,36 @@ protected function setUp(): void { parent::setUp(); - $nodeType = $this - ->getMockBuilder(NodeType::class) - ->setMethods(['getName', 'getLabel']) - ->disableOriginalConstructor() - ->getMock(); - $nodeType - ->method('getName') - ->willReturn('Neos.Neos:Content.Text'); - $nodeType - ->method('getLabel') - ->willReturn('Content.Text'); - - $textNodeProperties = $this - ->getMockBuilder(PropertyCollectionInterface::class) - ->getMock(); - $textNodeProperties - ->method('offsetExists') - ->willReturnCallback(function ($arg) { - return $arg === 'title' || $arg === 'text'; - }); - $textNodeProperties - ->method('offsetGet') - ->willReturnCallback(function ($arg) { - if ($arg === 'title') { - return 'Some title'; - } - if ($arg === 'text') { - return 'Some text'; - } - return null; - }); + $nodeSubjectProvider = new NodeSubjectProvider(); + + $textNodeType = new NodeType( + NodeTypeName::fromString('Neos.Neos:Content.Text'), + [], + [ + 'ui' => [ + 'label' => 'Content.Text' + ] + ], + new NodeTypeManager( + fn () => [], + new DefaultNodeLabelGeneratorFactory() + ), + new DefaultNodeLabelGeneratorFactory() + ); + + $textNodeProperties = new PropertyCollection( + SerializedPropertyValues::fromArray([ + 'title' => new SerializedPropertyValue( + 'Some title', + 'string' + ), + 'text' => new SerializedPropertyValue( + 'Some text', + 'string' + ), + ]), + $nodeSubjectProvider->propertyConverter + ); $now = new \DateTimeImmutable(); @@ -162,7 +166,7 @@ protected function setUp(): void OriginDimensionSpacePoint::fromArray([]), NodeAggregateClassification::CLASSIFICATION_REGULAR, NodeTypeName::fromString("nt"), - $nodeType, + $textNodeType, $textNodeProperties, null, Timestamps::create($now, $now, null, null) From c8373fde6cf4a71b6c4d9f6b7fddbb60b650607e Mon Sep 17 00:00:00 2001 From: Bernhard Schmitt Date: Fri, 1 Sep 2023 18:19:26 +0200 Subject: [PATCH 09/26] Make NodeHelperTest a proper functional test --- .../Tests/Functional/Fusion/NodeHelperTest.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Neos.Neos/Tests/Functional/Fusion/NodeHelperTest.php b/Neos.Neos/Tests/Functional/Fusion/NodeHelperTest.php index 2bb7433c6d5..f7e2f2cc7c2 100644 --- a/Neos.Neos/Tests/Functional/Fusion/NodeHelperTest.php +++ b/Neos.Neos/Tests/Functional/Fusion/NodeHelperTest.php @@ -29,6 +29,7 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; use Neos\ContentRepository\TestSuite\Unit\NodeSubjectProvider; +use Neos\ContentRepositoryRegistry\TestSuite\Behavior\CRRegistrySubjectProvider; use Neos\Fusion\Tests\Functional\FusionObjects\AbstractFusionObjectTest; use PHPUnit\Framework\MockObject\MockObject; @@ -37,6 +38,8 @@ */ class NodeHelperTest extends AbstractFusionObjectTest { + use CRRegistrySubjectProvider; + /** * @var Node|MockObject */ @@ -121,11 +124,14 @@ protected function buildView() protected function setUp(): void { parent::setUp(); - + $this->setUpCRRegistry(); + $contentRepositoryId = ContentRepositoryId::fromString('default'); + $this->iInitializeContentRepository($contentRepositoryId->value); $nodeSubjectProvider = new NodeSubjectProvider(); + $nodeTypeName = NodeTypeName::fromString('Neos.Neos:Content.Text'); $textNodeType = new NodeType( - NodeTypeName::fromString('Neos.Neos:Content.Text'), + $nodeTypeName, [], [ 'ui' => [ @@ -157,7 +163,7 @@ protected function setUp(): void $this->textNode = new Node( ContentSubgraphIdentity::create( - ContentRepositoryId::fromString("cr"), + $contentRepositoryId, ContentStreamId::fromString("cs"), DimensionSpacePoint::fromArray([]), VisibilityConstraints::withoutRestrictions() @@ -165,7 +171,7 @@ protected function setUp(): void NodeAggregateId::fromString("na"), OriginDimensionSpacePoint::fromArray([]), NodeAggregateClassification::CLASSIFICATION_REGULAR, - NodeTypeName::fromString("nt"), + $nodeTypeName, $textNodeType, $textNodeProperties, null, From 364a230f4e2568f9a7f59a9aad18c17927fc2f91 Mon Sep 17 00:00:00 2001 From: Bernhard Schmitt Date: Fri, 8 Sep 2023 12:44:05 +0200 Subject: [PATCH 10/26] Extract CR registry injection --- .../Privilege/Node/NodePrivilegeContext.php | 2 ++ .../Utility/ContentRepositoryRegistryProvider.php | 15 +++++++++++++++ .../Controller/Backend/ContentController.php | 2 ++ .../Controller/Frontend/NodeController.php | 2 ++ .../Domain/Service/NodeSiteResolvingService.php | 2 ++ .../Classes/Domain/Service/SiteNodeUtility.php | 2 ++ .../ContentRepositoryIntegrationService.php | 2 ++ Neos.Neos/Classes/Fusion/Helper/NodeHelper.php | 2 ++ .../Classes/Routing/Cache/RouteCacheFlusher.php | 2 ++ .../Utility/NodeTypeWithFallbackProvider.php | 6 ++---- Neos.Neos/Classes/View/FusionView.php | 2 ++ .../Backend/DocumentBreadcrumbPathViewHelper.php | 2 ++ .../Classes/ViewHelpers/Link/NodeViewHelper.php | 2 ++ 13 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 Neos.ContentRepositoryRegistry/Classes/Utility/ContentRepositoryRegistryProvider.php diff --git a/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php b/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php index 087e0a2c56b..1609220ca3d 100644 --- a/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php +++ b/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php @@ -17,6 +17,7 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindAncestorNodesFilter; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; +use Neos\ContentRepositoryRegistry\Utility\ContentRepositoryRegistryProvider; use Neos\Flow\Annotations as Flow; use Neos\Flow\Security\Context as SecurityContext; use Neos\Neos\Utility\NodeTypeWithFallbackProvider; @@ -26,6 +27,7 @@ */ class NodePrivilegeContext { + use ContentRepositoryRegistryProvider; use NodeTypeWithFallbackProvider; /** diff --git a/Neos.ContentRepositoryRegistry/Classes/Utility/ContentRepositoryRegistryProvider.php b/Neos.ContentRepositoryRegistry/Classes/Utility/ContentRepositoryRegistryProvider.php new file mode 100644 index 00000000000..b116b2ab748 --- /dev/null +++ b/Neos.ContentRepositoryRegistry/Classes/Utility/ContentRepositoryRegistryProvider.php @@ -0,0 +1,15 @@ + Date: Fri, 8 Sep 2023 12:53:18 +0200 Subject: [PATCH 11/26] Ask the NodeTypeManager for existence of node types instead of catching exceptions --- .../src/Domain/Repository/NodeFactory.php | 9 ++++----- .../src/Domain/Repository/NodeFactory.php | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/NodeFactory.php b/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/NodeFactory.php index 3caeedfd5d1..0ac6f2e1aad 100644 --- a/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/NodeFactory.php +++ b/Neos.ContentGraph.DoctrineDbalAdapter/src/Domain/Repository/NodeFactory.php @@ -63,11 +63,10 @@ public function mapNodeRowToNode( DimensionSpacePoint $dimensionSpacePoint, VisibilityConstraints $visibilityConstraints ): Node { - try { - $nodeType = $this->nodeTypeManager->getNodeType($nodeRow['nodetypename']); - } catch (NodeTypeNotFoundException $exception) { - $nodeType = null; - } + $nodeType = $this->nodeTypeManager->hasNodeType($nodeRow['nodetypename']) + ? $this->nodeTypeManager->getNodeType($nodeRow['nodetypename']) + : null; + return new Node( ContentSubgraphIdentity::create( $this->contentRepositoryId, diff --git a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/NodeFactory.php b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/NodeFactory.php index a754346b794..4ea8b4956f2 100644 --- a/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/NodeFactory.php +++ b/Neos.ContentGraph.PostgreSQLAdapter/src/Domain/Repository/NodeFactory.php @@ -72,11 +72,10 @@ public function mapNodeRowToNode( ?DimensionSpacePoint $dimensionSpacePoint = null, ?ContentStreamId $contentStreamId = null ): Node { - try { - $nodeType = $this->nodeTypeManager->getNodeType($nodeRow['nodetypename']); - } catch (NodeTypeNotFoundException $exception) { - $nodeType = null; - } + $nodeType = $this->nodeTypeManager->hasNodeType($nodeRow['nodetypename']) + ? $this->nodeTypeManager->getNodeType($nodeRow['nodetypename']) + : null; + return new Node( ContentSubgraphIdentity::create( $this->contentRepositoryId, From 8de00622a2eb1cd435447ebb97d8edbae4baa89f Mon Sep 17 00:00:00 2001 From: Bernhard Schmitt Date: Fri, 8 Sep 2023 12:57:54 +0200 Subject: [PATCH 12/26] Adjust NodeType documentation --- .../Classes/Projection/ContentGraph/Node.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php index adc0ca962a2..d76f280d1a4 100644 --- a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php +++ b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php @@ -63,7 +63,8 @@ public function __construct( public NodeTypeName $nodeTypeName, /** * The node's node type, null if unknown to the NodeTypeManager - * @deprecated Ask the NodeTypeManager instead + * @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 */ public ?NodeType $nodeType, /** From 059aa826a485644fc993e541929f86d9389769bc Mon Sep 17 00:00:00 2001 From: Bernhard Schmitt Date: Fri, 8 Sep 2023 13:01:38 +0200 Subject: [PATCH 13/26] Ask NodeTypeManager for node type instead of catching exceptions --- .../Classes/Utility/NodeTypeWithFallbackProvider.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Neos.Neos/Classes/Utility/NodeTypeWithFallbackProvider.php b/Neos.Neos/Classes/Utility/NodeTypeWithFallbackProvider.php index 58eda765823..93d62807282 100644 --- a/Neos.Neos/Classes/Utility/NodeTypeWithFallbackProvider.php +++ b/Neos.Neos/Classes/Utility/NodeTypeWithFallbackProvider.php @@ -1,10 +1,11 @@ contentRepositoryRegistry->get($node->subgraphIdentity->contentRepositoryId)->getNodeTypeManager(); - try { - return $nodeTypeManager->getNodeType($node->nodeTypeName); - } catch (NodeTypeNotFoundException) { - return $nodeTypeManager->getNodeType(NodeTypeNameFactory::forFallback()); - } + return $nodeTypeManager->hasNodeType($node->nodeTypeName) + ? $nodeTypeManager->getNodeType($node->nodeTypeName) + : $nodeTypeManager->getNodeType(NodeTypeNameFactory::forFallback()); } } From 20480e96f29c3fc90f475cd0ef362d3cbef05914 Mon Sep 17 00:00:00 2001 From: Bernhard Schmitt Date: Fri, 8 Sep 2023 13:04:36 +0200 Subject: [PATCH 14/26] Remove Fallback node configuration --- Neos.ContentRepositoryRegistry/Configuration/Settings.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/Neos.ContentRepositoryRegistry/Configuration/Settings.yaml b/Neos.ContentRepositoryRegistry/Configuration/Settings.yaml index 44117db2c43..b8bea873b15 100644 --- a/Neos.ContentRepositoryRegistry/Configuration/Settings.yaml +++ b/Neos.ContentRepositoryRegistry/Configuration/Settings.yaml @@ -21,8 +21,6 @@ Neos: nodeTypeManager: factoryObjectName: Neos\ContentRepositoryRegistry\Factory\NodeTypeManager\DefaultNodeTypeManagerFactory - options: - fallbackNodeTypeName: Neos.Neos:FallbackNode contentDimensionSource: factoryObjectName: Neos\ContentRepositoryRegistry\Factory\ContentDimensionSource\ConfigurationBasedContentDimensionSourceFactory From c95d53d43c4a6ae9618debfcdf764c963c007cbc Mon Sep 17 00:00:00 2001 From: Bernhard Schmitt Date: Fri, 8 Sep 2023 13:16:44 +0200 Subject: [PATCH 15/26] Remove fallback node documentation --- Neos.Neos/Configuration/Settings.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Neos.Neos/Configuration/Settings.yaml b/Neos.Neos/Configuration/Settings.yaml index 6becebb2d32..0c1d7b595c2 100755 --- a/Neos.Neos/Configuration/Settings.yaml +++ b/Neos.Neos/Configuration/Settings.yaml @@ -516,11 +516,6 @@ Neos: neos-plugin: Plugins ContentRepository: - # This instructs neos to fallback to the given type if a node type can't be found (because it was removed or has - # been renamed for example). The default "Neos.Neos:FallbackNode" renders a warning in backend and is ignored - # in frontend rendering - fallbackNodeType: 'Neos.Neos:FallbackNode' - # Definition of available content dimensions. Additional content dimensions may be defined in third-party packages # or via global settings. # From bbcf65a0f89ee8a31371209c1b3342469121494e Mon Sep 17 00:00:00 2001 From: Bernhard Schmitt Date: Fri, 8 Sep 2023 19:00:55 +0200 Subject: [PATCH 16/26] Fix CR registry provider docs --- .../Classes/Utility/ContentRepositoryRegistryProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Neos.ContentRepositoryRegistry/Classes/Utility/ContentRepositoryRegistryProvider.php b/Neos.ContentRepositoryRegistry/Classes/Utility/ContentRepositoryRegistryProvider.php index b116b2ab748..432291627ad 100644 --- a/Neos.ContentRepositoryRegistry/Classes/Utility/ContentRepositoryRegistryProvider.php +++ b/Neos.ContentRepositoryRegistry/Classes/Utility/ContentRepositoryRegistryProvider.php @@ -6,7 +6,7 @@ use Neos\Flow\Annotations as Flow; /** - * Utility trait for retrieving node types for nodes with a built-in fallback mechanism + * Utility trait for providing the content repository registry */ trait ContentRepositoryRegistryProvider { From bae8a3d3f0e607851ebc032918106e4860f5a4bc Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Sun, 24 Sep 2023 22:38:18 +0200 Subject: [PATCH 17/26] TASK: Remove `ContentRepositoryRegistryProvider` and use "classic" _protected var pattern in trait Introducing the pattern with the additional `ContentRepositoryRegistryProvider` makes things just more complex and less obvious. While not perfectly "clean" we instead import in the `NodeTypeWithFallbackProvider` trait the `ContentRepositoryRegistry` via $_contentRepositoryRegistry. This pattern is already used across the codebase. --- .../Privilege/Node/NodePrivilegeContext.php | 5 +++-- .../Utility/ContentRepositoryRegistryProvider.php | 15 --------------- .../Controller/Backend/ContentController.php | 5 +++-- .../Controller/Frontend/NodeController.php | 5 +++-- .../Domain/Service/NodeSiteResolvingService.php | 5 +++-- .../Classes/Domain/Service/SiteNodeUtility.php | 5 +++-- .../ContentRepositoryIntegrationService.php | 5 +++-- Neos.Neos/Classes/Fusion/Helper/NodeHelper.php | 5 +++-- .../Classes/Routing/Cache/RouteCacheFlusher.php | 5 +++-- .../Utility/NodeTypeWithFallbackProvider.php | 8 +++++--- Neos.Neos/Classes/View/FusionView.php | 5 +++-- .../Backend/DocumentBreadcrumbPathViewHelper.php | 5 +++-- .../Classes/ViewHelpers/Link/NodeViewHelper.php | 5 +++-- 13 files changed, 38 insertions(+), 40 deletions(-) delete mode 100644 Neos.ContentRepositoryRegistry/Classes/Utility/ContentRepositoryRegistryProvider.php diff --git a/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php b/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php index 1609220ca3d..06c39096c5a 100644 --- a/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php +++ b/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php @@ -17,7 +17,6 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindAncestorNodesFilter; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; -use Neos\ContentRepositoryRegistry\Utility\ContentRepositoryRegistryProvider; use Neos\Flow\Annotations as Flow; use Neos\Flow\Security\Context as SecurityContext; use Neos\Neos\Utility\NodeTypeWithFallbackProvider; @@ -27,9 +26,11 @@ */ class NodePrivilegeContext { - use ContentRepositoryRegistryProvider; use NodeTypeWithFallbackProvider; + #[Flow\Inject] + protected ContentRepositoryRegistry $contentRepositoryRegistry; + /** * @Flow\Inject * @var SecurityContext diff --git a/Neos.ContentRepositoryRegistry/Classes/Utility/ContentRepositoryRegistryProvider.php b/Neos.ContentRepositoryRegistry/Classes/Utility/ContentRepositoryRegistryProvider.php deleted file mode 100644 index 432291627ad..00000000000 --- a/Neos.ContentRepositoryRegistry/Classes/Utility/ContentRepositoryRegistryProvider.php +++ /dev/null @@ -1,15 +0,0 @@ -contentRepositoryRegistry->get($node->subgraphIdentity->contentRepositoryId)->getNodeTypeManager(); + $nodeTypeManager = $this->_contentRepositoryRegistry->get($node->subgraphIdentity->contentRepositoryId)->getNodeTypeManager(); return $nodeTypeManager->hasNodeType($node->nodeTypeName) ? $nodeTypeManager->getNodeType($node->nodeTypeName) diff --git a/Neos.Neos/Classes/View/FusionView.php b/Neos.Neos/Classes/View/FusionView.php index 0183572e541..0596705c97e 100644 --- a/Neos.Neos/Classes/View/FusionView.php +++ b/Neos.Neos/Classes/View/FusionView.php @@ -16,7 +16,6 @@ use GuzzleHttp\Psr7\Message; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; -use Neos\ContentRepositoryRegistry\Utility\ContentRepositoryRegistryProvider; use Neos\Flow\Annotations as Flow; use Neos\Flow\Mvc\View\AbstractView; use Neos\Flow\Security\Context; @@ -40,9 +39,11 @@ class FusionView extends AbstractView { use FusionViewI18nTrait; - use ContentRepositoryRegistryProvider; use NodeTypeWithFallbackProvider; + #[Flow\Inject] + protected ContentRepositoryRegistry $contentRepositoryRegistry; + /** * @Flow\Inject * @var SiteNodeUtility diff --git a/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php b/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php index 0e07cef55a4..3757f98c837 100644 --- a/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php +++ b/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php @@ -15,7 +15,6 @@ namespace Neos\Neos\ViewHelpers\Backend; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; -use Neos\ContentRepositoryRegistry\Utility\ContentRepositoryRegistryProvider; use Neos\Flow\Annotations as Flow; use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper; use Neos\Neos\Domain\Service\NodeTypeNameFactory; @@ -26,9 +25,11 @@ */ class DocumentBreadcrumbPathViewHelper extends AbstractViewHelper { - use ContentRepositoryRegistryProvider; use NodeTypeWithFallbackProvider; + #[Flow\Inject] + protected ContentRepositoryRegistry $contentRepositoryRegistry; + /** * @var boolean */ diff --git a/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php b/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php index f5ab5cfa033..4b80aad2419 100644 --- a/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php +++ b/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php @@ -18,7 +18,6 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\Projection\ContentGraph\NodePath; -use Neos\ContentRepositoryRegistry\Utility\ContentRepositoryRegistryProvider; use Neos\Neos\Domain\Service\NodeTypeNameFactory; use Neos\Neos\FrontendRouting\NodeAddress; use Neos\Neos\FrontendRouting\NodeAddressFactory; @@ -127,9 +126,11 @@ class NodeViewHelper extends AbstractTagBasedViewHelper { use FusionContextTrait; - use ContentRepositoryRegistryProvider; use NodeTypeWithFallbackProvider; + #[Flow\Inject] + protected ContentRepositoryRegistry $contentRepositoryRegistry; + /** * @var string */ From 7f2dc541f0133b01905c9113d27aae84a474fbd2 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Sun, 24 Sep 2023 23:38:42 +0200 Subject: [PATCH 18/26] TASK: `NodeTypeWithFallbackProvider` don't reimport `contentRepositoryRegistry` but declare that property must exist phpstan will catch invalid use of this trait --- .../Classes/Utility/NodeTypeWithFallbackProvider.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Neos.Neos/Classes/Utility/NodeTypeWithFallbackProvider.php b/Neos.Neos/Classes/Utility/NodeTypeWithFallbackProvider.php index 67057da1226..5cc304c3fc1 100644 --- a/Neos.Neos/Classes/Utility/NodeTypeWithFallbackProvider.php +++ b/Neos.Neos/Classes/Utility/NodeTypeWithFallbackProvider.php @@ -7,20 +7,18 @@ use Neos\ContentRepository\Core\NodeType\NodeType; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; -use Neos\Flow\Annotations as Flow; use Neos\Neos\Domain\Service\NodeTypeNameFactory; /** * Utility trait for retrieving node types for nodes with a built-in fallback mechanism + * + * @property ContentRepositoryRegistry $contentRepositoryRegistry */ trait NodeTypeWithFallbackProvider { - #[Flow\Inject] - protected ContentRepositoryRegistry $_contentRepositoryRegistry; - protected function getNodeType(Node $node): NodeType { - $nodeTypeManager = $this->_contentRepositoryRegistry->get($node->subgraphIdentity->contentRepositoryId)->getNodeTypeManager(); + $nodeTypeManager = $this->contentRepositoryRegistry->get($node->subgraphIdentity->contentRepositoryId)->getNodeTypeManager(); return $nodeTypeManager->hasNodeType($node->nodeTypeName) ? $nodeTypeManager->getNodeType($node->nodeTypeName) From f8e875f44717c6879e22e8bb346031900a06b8b3 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Mon, 25 Sep 2023 11:10:08 +0200 Subject: [PATCH 19/26] TASK: Deactivate `NodeHelperTest` for now --- Neos.Neos/Tests/Functional/Fusion/NodeHelperTest.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Neos.Neos/Tests/Functional/Fusion/NodeHelperTest.php b/Neos.Neos/Tests/Functional/Fusion/NodeHelperTest.php index fbd85222ddf..7ae29c33826 100644 --- a/Neos.Neos/Tests/Functional/Fusion/NodeHelperTest.php +++ b/Neos.Neos/Tests/Functional/Fusion/NodeHelperTest.php @@ -13,12 +13,11 @@ use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint; -use Neos\ContentRepository\Core\Factory\ContentRepositoryId; use Neos\ContentRepository\Core\Feature\NodeModification\Dto\SerializedPropertyValue; use Neos\ContentRepository\Core\Feature\NodeModification\Dto\SerializedPropertyValues; use Neos\ContentRepository\Core\NodeType\DefaultNodeLabelGeneratorFactory; -use Neos\ContentRepository\Core\NodeType\NodeTypeManager; use Neos\ContentRepository\Core\NodeType\NodeType; +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\Node; @@ -29,7 +28,6 @@ use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; use Neos\ContentRepository\TestSuite\Unit\NodeSubjectProvider; -use Neos\ContentRepositoryRegistry\TestSuite\Behavior\CRRegistrySubjectProvider; use Neos\Fusion\Tests\Functional\FusionObjects\AbstractFusionObjectTest; use PHPUnit\Framework\MockObject\MockObject; @@ -38,8 +36,6 @@ */ class NodeHelperTest extends AbstractFusionObjectTest { - use CRRegistrySubjectProvider; - /** * @var Node|MockObject */ @@ -125,12 +121,10 @@ protected function setUp(): void { $this->markTestSkipped('Skipped until we find a better way to mock node read models (see https://github.com/neos/neos-development-collection/issues/4317)'); parent::setUp(); - $this->setUpCRRegistry(); - $contentRepositoryId = ContentRepositoryId::fromString('default'); - $this->iInitializeContentRepository($contentRepositoryId->value); $nodeSubjectProvider = new NodeSubjectProvider(); $nodeTypeName = NodeTypeName::fromString('Neos.Neos:Content.Text'); + // todo injecting the mocked nodeType in the node doesnt matter, as the nodeType is fetched from the nodeTypeManager in the NodeHelper $textNodeType = new NodeType( $nodeTypeName, [], From 907801552432e0eb75c6f5e4a87b87c2cc258eb3 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Mon, 25 Sep 2023 11:20:15 +0200 Subject: [PATCH 20/26] TASK: Remove hacky legacy `LoadNodeTypeTrait` --- .../DisallowedChildNodeAdjustment.php | 29 +++++++------------ .../src/Adjustment/LoadNodeTypeTrait.php | 28 ------------------ .../src/Adjustment/PropertyAdjustment.php | 12 ++------ .../Adjustment/TetheredNodeAdjustments.php | 11 ++----- .../Adjustment/UnknownNodeTypeAdjustment.php | 9 +----- 5 files changed, 17 insertions(+), 72 deletions(-) delete mode 100644 Neos.ContentRepository.StructureAdjustment/src/Adjustment/LoadNodeTypeTrait.php diff --git a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/DisallowedChildNodeAdjustment.php b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/DisallowedChildNodeAdjustment.php index 0dfa463e7ee..a8b1c362855 100644 --- a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/DisallowedChildNodeAdjustment.php +++ b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/DisallowedChildNodeAdjustment.php @@ -7,23 +7,21 @@ use Neos\ContentRepository\Core\ContentRepository; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet; +use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint; +use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePointSet; use Neos\ContentRepository\Core\EventStore\Events; use Neos\ContentRepository\Core\EventStore\EventsToPublish; use Neos\ContentRepository\Core\Feature\ContentStreamEventStreamName; use Neos\ContentRepository\Core\Feature\NodeRemoval\Event\NodeAggregateWasRemoved; -use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate; -use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint; -use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePointSet; use Neos\ContentRepository\Core\NodeType\NodeTypeManager; use Neos\ContentRepository\Core\NodeType\NodeTypeName; -use Neos\ContentRepository\Core\SharedModel\User\UserId; +use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate; use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints; use Neos\EventStore\Model\EventStream\ExpectedVersion; class DisallowedChildNodeAdjustment { use RemoveNodeAggregateTrait; - use LoadNodeTypeTrait; public function __construct( private readonly ContentRepository $contentRepository, @@ -37,19 +35,17 @@ public function __construct( */ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generator { - $nodeType = $this->loadNodeType($nodeTypeName); - - if ($nodeType === null) { + if (!$this->nodeTypeManager->hasNodeType($nodeTypeName)) { // no adjustments for unknown node types return; } foreach ($this->projectedNodeIterator->nodeAggregatesOfType($nodeTypeName) as $nodeAggregate) { - $nodeType = $this->loadNodeType($nodeAggregate->nodeTypeName); - if ($nodeType === null) { + if (!$this->nodeTypeManager->hasNodeType($nodeAggregate->nodeTypeName)) { // unknown child node type, so we skip this test as we won't be able to find out node type constraints continue; } + $nodeType = $this->nodeTypeManager->getNodeType($nodeAggregate->nodeTypeName); // Here, we iterate over the covered dimension space points of the node aggregate one by one; // as it can happen that the constraint is only violated in e.g. "AT", but not in "DE". @@ -70,8 +66,8 @@ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generat $allowedByParent = true; $parentNodeType = null; if ($parentNode !== null) { - $parentNodeType = $this->loadNodeType($parentNode->nodeTypeName); - if ($parentNodeType !== null) { + if ($this->nodeTypeManager->hasNodeType($parentNode->nodeTypeName)) { + $parentNodeType = $this->nodeTypeManager->getNodeType($parentNode->nodeTypeName); $allowedByParent = $parentNodeType->allowsChildNodeType($nodeType); } } @@ -84,8 +80,8 @@ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generat && $parentNode->classification->isTethered() && !is_null($parentNode->nodeName) ) { - $grandparentNodeType = $this->loadNodeType($grandparentNode->nodeTypeName); - if ($grandparentNodeType !== null) { + if ($this->nodeTypeManager->hasNodeType($grandparentNode->nodeTypeName)) { + $grandparentNodeType = $this->nodeTypeManager->getNodeType($grandparentNode->nodeTypeName); $allowedByGrandparent = $grandparentNodeType->allowsGrandchildNodeType( $parentNode->nodeName->value, $nodeType @@ -153,9 +149,4 @@ private function removeNodeInSingleDimensionSpacePoint( ExpectedVersion::ANY() ); } - - protected function getNodeTypeManager(): NodeTypeManager - { - return $this->nodeTypeManager; - } } diff --git a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/LoadNodeTypeTrait.php b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/LoadNodeTypeTrait.php deleted file mode 100644 index d6f12df889e..00000000000 --- a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/LoadNodeTypeTrait.php +++ /dev/null @@ -1,28 +0,0 @@ -getNodeTypeManager()->getNodeType($nodeTypeName); - } catch (NodeTypeNotFoundException $e) { - // the $nodeTypeName was not found; so we need to remove all nodes of this type. - return null; - } - } -} diff --git a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/PropertyAdjustment.php b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/PropertyAdjustment.php index 2f45a28127b..f84c7a74524 100644 --- a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/PropertyAdjustment.php +++ b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/PropertyAdjustment.php @@ -18,8 +18,6 @@ class PropertyAdjustment { - use LoadNodeTypeTrait; - public function __construct( private readonly ProjectedNodeIterator $projectedNodeIterator, private readonly NodeTypeManager $nodeTypeManager @@ -31,11 +29,12 @@ public function __construct( */ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generator { - $nodeType = $this->loadNodeType($nodeTypeName); - if ($nodeType === null) { + if (!$this->nodeTypeManager->hasNodeType($nodeTypeName)) { // In case we cannot find the expected tethered nodes, this fix cannot do anything. return; } + $nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName); + $expectedPropertiesFromNodeType = array_filter($nodeType->getProperties(), fn ($value) => $value !== null); foreach ($this->projectedNodeIterator->nodeAggregatesOfType($nodeTypeName) as $nodeAggregate) { @@ -132,9 +131,4 @@ private function publishNodePropertiesWereSet( ExpectedVersion::ANY() ); } - - protected function getNodeTypeManager(): NodeTypeManager - { - return $this->nodeTypeManager; - } } diff --git a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/TetheredNodeAdjustments.php b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/TetheredNodeAdjustments.php index 7bff3925f22..aa50bb0324b 100644 --- a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/TetheredNodeAdjustments.php +++ b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/TetheredNodeAdjustments.php @@ -32,7 +32,6 @@ class TetheredNodeAdjustments { use NodeVariationInternals; use RemoveNodeAggregateTrait; - use LoadNodeTypeTrait; use TetheredNodeInternals; public function __construct( @@ -48,11 +47,12 @@ public function __construct( */ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generator { - $nodeType = $this->loadNodeType($nodeTypeName); - if ($nodeType === null) { + if (!$this->nodeTypeManager->hasNodeType($nodeTypeName)) { // In case we cannot find the expected tethered nodes, this fix cannot do anything. return; } + $nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName); + $expectedTetheredNodes = $nodeType->getAutoCreatedChildNodes(); foreach ($this->projectedNodeIterator->nodeAggregatesOfType($nodeTypeName) as $nodeAggregate) { @@ -204,11 +204,6 @@ protected function getInterDimensionalVariationGraph(): DimensionSpace\InterDime return $this->interDimensionalVariationGraph; } - protected function getNodeTypeManager(): NodeTypeManager - { - return $this->nodeTypeManager; - } - /** * array key: name of tethered child node. Value: the Node itself. * @param array $actualTetheredChildNodes diff --git a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/UnknownNodeTypeAdjustment.php b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/UnknownNodeTypeAdjustment.php index 903ae844770..e80657f3602 100644 --- a/Neos.ContentRepository.StructureAdjustment/src/Adjustment/UnknownNodeTypeAdjustment.php +++ b/Neos.ContentRepository.StructureAdjustment/src/Adjustment/UnknownNodeTypeAdjustment.php @@ -10,7 +10,6 @@ class UnknownNodeTypeAdjustment { use RemoveNodeAggregateTrait; - use LoadNodeTypeTrait; public function __construct( private readonly ProjectedNodeIterator $projectedNodeIterator, @@ -23,8 +22,7 @@ public function __construct( */ public function findAdjustmentsForNodeType(NodeTypeName $nodeTypeName): \Generator { - $nodeType = $this->loadNodeType($nodeTypeName); - if ($nodeType === null) { + if (!$this->nodeTypeManager->hasNodeType($nodeTypeName)) { // node type is not existing right now. yield from $this->removeAllNodesOfType($nodeTypeName); } @@ -47,9 +45,4 @@ function () use ($nodeAggregate) { ); } } - - protected function getNodeTypeManager(): NodeTypeManager - { - return $this->nodeTypeManager; - } } From e20071e0295c61e319cd493dc5f082bedf22bc36 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Mon, 25 Sep 2023 12:03:01 +0200 Subject: [PATCH 21/26] TASK: Correctly inject `ContentRepositoryRegistry` --- .../Authorization/Privilege/Node/NodePrivilegeContext.php | 1 + Neos.Neos/Classes/Controller/Backend/ContentController.php | 1 + Neos.Neos/Classes/Controller/Frontend/NodeController.php | 1 + .../Controller/Module/Management/WorkspacesController.php | 4 ++++ Neos.Neos/Classes/Domain/Service/NodeSiteResolvingService.php | 1 + Neos.Neos/Classes/Domain/Service/SiteNodeUtility.php | 1 + .../Integrations/ContentRepositoryIntegrationService.php | 1 + Neos.Neos/Classes/Fusion/Helper/NodeHelper.php | 2 ++ Neos.Neos/Classes/Fusion/Helper/NodeLabelToken.php | 4 ++++ Neos.Neos/Classes/Routing/Cache/RouteCacheFlusher.php | 1 + Neos.Neos/Classes/View/FusionView.php | 1 + .../ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php | 1 + Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php | 1 + 13 files changed, 20 insertions(+) diff --git a/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php b/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php index 06c39096c5a..456f2eec65a 100644 --- a/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php +++ b/Neos.ContentRepository.Security/Classes/Authorization/Privilege/Node/NodePrivilegeContext.php @@ -17,6 +17,7 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindAncestorNodesFilter; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; +use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Flow\Security\Context as SecurityContext; use Neos\Neos\Utility\NodeTypeWithFallbackProvider; diff --git a/Neos.Neos/Classes/Controller/Backend/ContentController.php b/Neos.Neos/Classes/Controller/Backend/ContentController.php index 14e470bd1b8..e6072a7bbc4 100644 --- a/Neos.Neos/Classes/Controller/Backend/ContentController.php +++ b/Neos.Neos/Classes/Controller/Backend/ContentController.php @@ -15,6 +15,7 @@ namespace Neos\Neos\Controller\Backend; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; +use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Neos\Domain\Service\NodeTypeNameFactory; use Neos\Neos\FrontendRouting\NodeAddressFactory; use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints; diff --git a/Neos.Neos/Classes/Controller/Frontend/NodeController.php b/Neos.Neos/Classes/Controller/Frontend/NodeController.php index 460ee7f4bdf..34c64b2ab69 100644 --- a/Neos.Neos/Classes/Controller/Frontend/NodeController.php +++ b/Neos.Neos/Classes/Controller/Frontend/NodeController.php @@ -24,6 +24,7 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Subtree; use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; +use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Flow\Mvc\Controller\ActionController; use Neos\Flow\Mvc\Exception\NoMatchingRouteException; diff --git a/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php b/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php index 4c46c227188..f6ce1f71385 100644 --- a/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php +++ b/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php @@ -20,6 +20,7 @@ use Neos\ContentRepository\Core\Feature\WorkspaceCreation\Exception\WorkspaceAlreadyExists; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindAncestorNodesFilter; use Neos\ContentRepository\Core\SharedModel\Node\NodeName; +use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\I18n\Exception\IndexOutOfBoundsException; use Neos\Flow\I18n\Exception\InvalidFormatPlaceholderException; use Neos\Flow\Mvc\Exception\StopActionException; @@ -73,6 +74,9 @@ class WorkspacesController extends AbstractModuleController use ModuleTranslationTrait; use NodeTypeWithFallbackProvider; + #[Flow\Inject] + protected ContentRepositoryRegistry $contentRepositoryRegistry; + /** * @Flow\Inject * @var SiteRepository diff --git a/Neos.Neos/Classes/Domain/Service/NodeSiteResolvingService.php b/Neos.Neos/Classes/Domain/Service/NodeSiteResolvingService.php index d01167d0609..49aa0564179 100644 --- a/Neos.Neos/Classes/Domain/Service/NodeSiteResolvingService.php +++ b/Neos.Neos/Classes/Domain/Service/NodeSiteResolvingService.php @@ -16,6 +16,7 @@ use Neos\ContentRepository\Core\Factory\ContentRepositoryId; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; +use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Neos\FrontendRouting\NodeAddress; use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints; use Neos\Flow\Annotations as Flow; diff --git a/Neos.Neos/Classes/Domain/Service/SiteNodeUtility.php b/Neos.Neos/Classes/Domain/Service/SiteNodeUtility.php index 5dc70e1537c..b24f43096c1 100644 --- a/Neos.Neos/Classes/Domain/Service/SiteNodeUtility.php +++ b/Neos.Neos/Classes/Domain/Service/SiteNodeUtility.php @@ -20,6 +20,7 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; +use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Neos\Domain\Model\Site; use Neos\Neos\Domain\Repository\DomainRepository; diff --git a/Neos.Neos/Classes/EventLog/Integrations/ContentRepositoryIntegrationService.php b/Neos.Neos/Classes/EventLog/Integrations/ContentRepositoryIntegrationService.php index 49753d8214d..94c807e6cad 100644 --- a/Neos.Neos/Classes/EventLog/Integrations/ContentRepositoryIntegrationService.php +++ b/Neos.Neos/Classes/EventLog/Integrations/ContentRepositoryIntegrationService.php @@ -17,6 +17,7 @@ use Doctrine\ORM\EntityManagerInterface; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\Projection\Workspace\Workspace; +use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Neos\FrontendRouting\NodeAddressFactory; use Neos\Flow\Annotations as Flow; use Neos\Flow\Persistence\PersistenceManagerInterface; diff --git a/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php b/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php index 64792ef050a..8bf7f0c68e6 100644 --- a/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php +++ b/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php @@ -18,6 +18,7 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\CountAncestorNodesFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindAncestorNodesFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\NodePath; +use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Neos\Domain\Service\NodeTypeNameFactory; use Neos\Neos\FrontendRouting\NodeAddressFactory; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; @@ -25,6 +26,7 @@ use Neos\Neos\Domain\Exception; use Neos\Neos\Presentation\VisualNodePath; use Neos\Neos\Utility\NodeTypeWithFallbackProvider; +use Neos\Flow\Annotations as Flow; /** * Eel helper for ContentRepository Nodes diff --git a/Neos.Neos/Classes/Fusion/Helper/NodeLabelToken.php b/Neos.Neos/Classes/Fusion/Helper/NodeLabelToken.php index 485fb42f194..cf63385c03c 100644 --- a/Neos.Neos/Classes/Fusion/Helper/NodeLabelToken.php +++ b/Neos.Neos/Classes/Fusion/Helper/NodeLabelToken.php @@ -15,6 +15,7 @@ namespace Neos\Neos\Fusion\Helper; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; +use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Eel\Helper\StringHelper; use Neos\Eel\ProtectedContextAwareInterface; use Neos\Flow\Annotations as Flow; @@ -29,6 +30,9 @@ class NodeLabelToken implements ProtectedContextAwareInterface { use NodeTypeWithFallbackProvider; + #[Flow\Inject] + protected ContentRepositoryRegistry $contentRepositoryRegistry; + /** * @Flow\Inject * @var TranslationHelper diff --git a/Neos.Neos/Classes/Routing/Cache/RouteCacheFlusher.php b/Neos.Neos/Classes/Routing/Cache/RouteCacheFlusher.php index 0e91960e500..14507af46af 100644 --- a/Neos.Neos/Classes/Routing/Cache/RouteCacheFlusher.php +++ b/Neos.Neos/Classes/Routing/Cache/RouteCacheFlusher.php @@ -16,6 +16,7 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\Projection\Workspace\Workspace; +use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Flow\Mvc\Routing\RouterCachingService; use Neos\Neos\Domain\Service\NodeTypeNameFactory; diff --git a/Neos.Neos/Classes/View/FusionView.php b/Neos.Neos/Classes/View/FusionView.php index 0596705c97e..29a469857d8 100644 --- a/Neos.Neos/Classes/View/FusionView.php +++ b/Neos.Neos/Classes/View/FusionView.php @@ -16,6 +16,7 @@ use GuzzleHttp\Psr7\Message; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; +use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Flow\Mvc\View\AbstractView; use Neos\Flow\Security\Context; diff --git a/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php b/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php index 3757f98c837..4ca88d29f08 100644 --- a/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php +++ b/Neos.Neos/Classes/ViewHelpers/Backend/DocumentBreadcrumbPathViewHelper.php @@ -15,6 +15,7 @@ namespace Neos\Neos\ViewHelpers\Backend; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; +use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper; use Neos\Neos\Domain\Service\NodeTypeNameFactory; diff --git a/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php b/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php index 4b80aad2419..bb81fab4a05 100644 --- a/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php +++ b/Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php @@ -18,6 +18,7 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\Projection\ContentGraph\NodePath; +use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Neos\Domain\Service\NodeTypeNameFactory; use Neos\Neos\FrontendRouting\NodeAddress; use Neos\Neos\FrontendRouting\NodeAddressFactory; From a8b12ffa4a03d71eab79dc727445d07dca9f5e56 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Mon, 25 Sep 2023 16:51:45 +0200 Subject: [PATCH 22/26] BUGFIX: Fix `Neos.Neos:FallbackNode` rendering --- Neos.Neos/Classes/Fusion/Helper/NodeHelper.php | 12 ++++++++++-- .../Private/Fusion/Prototypes/ContentCase.fusion | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php b/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php index 8bf7f0c68e6..54384747a8b 100644 --- a/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php +++ b/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php @@ -14,6 +14,7 @@ namespace Neos\Neos\Fusion\Helper; +use Neos\ContentRepository\Core\NodeType\NodeType; use Neos\ContentRepository\Core\Projection\ContentGraph\AbsoluteNodePath; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\CountAncestorNodesFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindAncestorNodesFilter; @@ -33,7 +34,9 @@ */ class NodeHelper implements ProtectedContextAwareInterface { - use NodeTypeWithFallbackProvider; + use NodeTypeWithFallbackProvider { + getNodeType as getNodeTypeInternal; + } #[Flow\Inject] protected ContentRepositoryRegistry $contentRepositoryRegistry; @@ -130,7 +133,12 @@ public function path(Node $node): string */ public function isOfType(Node $node, string $nodeType): bool { - return $this->getNodeType($node)->isOfType($nodeType); + return $this->getNodeTypeInternal($node)->isOfType($nodeType); + } + + public function getNodeType(Node $node): NodeType + { + return $this->getNodeTypeInternal($node); } public function serializedNodeAddress(Node $node): string diff --git a/Neos.Neos/Resources/Private/Fusion/Prototypes/ContentCase.fusion b/Neos.Neos/Resources/Private/Fusion/Prototypes/ContentCase.fusion index 5a0a7152f0e..cc1544d9301 100644 --- a/Neos.Neos/Resources/Private/Fusion/Prototypes/ContentCase.fusion +++ b/Neos.Neos/Resources/Private/Fusion/Prototypes/ContentCase.fusion @@ -6,6 +6,6 @@ prototype(Neos.Neos:ContentCase) < prototype(Neos.Fusion:Case) { default { @position = 'end' condition = true - type = ${node.nodeType.name} + type = ${Neos.Node.getNodeType(node).name} } } From f1bceca566f4674421ef8c39aaccb4a3563c4210 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Tue, 26 Sep 2023 23:02:45 +0200 Subject: [PATCH 23/26] TASK: Adjust `NodeTypesCommandController` to changes in NodeTypeManager --- .../Classes/Command/NodeTypesCommandController.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Neos.ContentRepositoryRegistry/Classes/Command/NodeTypesCommandController.php b/Neos.ContentRepositoryRegistry/Classes/Command/NodeTypesCommandController.php index 6901a5c6132..faf64e498b4 100644 --- a/Neos.ContentRepositoryRegistry/Classes/Command/NodeTypesCommandController.php +++ b/Neos.ContentRepositoryRegistry/Classes/Command/NodeTypesCommandController.php @@ -39,11 +39,12 @@ public function showCommand(string $nodeTypeName, ?string $path = null, string $ $contentRepositoryId = ContentRepositoryId::fromString($contentRepository); $nodeTypeManager = $this->contentRepositoryRegistry->get($contentRepositoryId)->getNodeTypeManager(); - $nodeType = $nodeTypeManager->getNodeType($nodeTypeName); - if (!$nodeType) { + if (!$nodeTypeManager->hasNodeType($nodeTypeName)) { $this->outputLine('NodeType "%s" was not found!', [$nodeTypeName]); $this->quit(); } + + $nodeType = $nodeTypeManager->getNodeType($nodeTypeName); $yaml = Yaml::dump( $path ? $nodeType->getConfiguration($path) @@ -71,7 +72,7 @@ public function listCommand(?string $filter = null, bool $includeAbstract = true $nodeTypesFound = 0; $nodeTypeNameSpacesWithNodeTypeNames = []; foreach ($nodeTypeManager->getNodeTypes($includeAbstract) as $nodeType) { - $nodeTypeName = $nodeType->getName(); + $nodeTypeName = $nodeType->name->value; if (!$filter || str_contains($nodeTypeName, $filter)) { [$nameSpace] = explode(":", $nodeTypeName, 2); $nodeTypeNameSpacesWithNodeTypeNames[$nameSpace][] = $nodeTypeName; From 844ad46a5d2a2cbff7904bd1a2054b670495ca01 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Tue, 26 Sep 2023 23:10:42 +0200 Subject: [PATCH 24/26] !!! TASK: Remove `NodeType::getName()` and replace usages Resolves: #4560 --- .../Classes/NodeType/NodeType.php | 9 --------- .../Resources/Private/Fusion/Prototypes/Content.fusion | 2 +- .../Resources/Private/Fusion/RawContent/Node.fusion | 2 +- Neos.Neos/Resources/Private/Fusion/RootCase.fusion | 6 +++--- .../Resources/Private/Fusion/Root.fusion | 2 +- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/Neos.ContentRepository.Core/Classes/NodeType/NodeType.php b/Neos.ContentRepository.Core/Classes/NodeType/NodeType.php index 1099e8c6a38..94ab651a41c 100644 --- a/Neos.ContentRepository.Core/Classes/NodeType/NodeType.php +++ b/Neos.ContentRepository.Core/Classes/NodeType/NodeType.php @@ -223,15 +223,6 @@ protected function applyPostprocessing(array $fullConfiguration): array return $fullConfiguration; } - /** - * Returns the name of this node type - * @deprecated use "name" property directly - */ - public function getName(): string - { - return $this->name->value; - } - /** * Return boolean true if marked abstract */ diff --git a/Neos.Neos/Resources/Private/Fusion/Prototypes/Content.fusion b/Neos.Neos/Resources/Private/Fusion/Prototypes/Content.fusion index fbd82078ffd..ced9c9d367f 100644 --- a/Neos.Neos/Resources/Private/Fusion/Prototypes/Content.fusion +++ b/Neos.Neos/Resources/Private/Fusion/Prototypes/Content.fusion @@ -18,7 +18,7 @@ prototype(Neos.Neos:Content) < prototype(Neos.Fusion:Template) { # attributes.class.@process.nodeType > # } # in your site's Fusion if you don't need that behavior. - attributes.class.@process.nodeType = ${Array.push(value, String.toLowerCase(String.pregReplace(node.nodeType.name, '/[[:^alnum:]]/', '-')))} + attributes.class.@process.nodeType = ${Array.push(value, String.toLowerCase(String.pregReplace(node.nodeTypeName.value, '/[[:^alnum:]]/', '-')))} # The following line must not be removed as it adds required meta data to all content elements in backend @process.contentElementWrapping { diff --git a/Neos.Neos/Resources/Private/Fusion/RawContent/Node.fusion b/Neos.Neos/Resources/Private/Fusion/RawContent/Node.fusion index c977e308285..47ac7fb8562 100644 --- a/Neos.Neos/Resources/Private/Fusion/RawContent/Node.fusion +++ b/Neos.Neos/Resources/Private/Fusion/RawContent/Node.fusion @@ -1,6 +1,6 @@ prototype(Neos.Neos:RawContent.Node) < prototype(Neos.Neos:ContentComponent) { - nodeType = ${node.nodeType.name} + nodeType = ${node.nodeTypeName.value} renderer = Neos.Fusion:Case { custom { diff --git a/Neos.Neos/Resources/Private/Fusion/RootCase.fusion b/Neos.Neos/Resources/Private/Fusion/RootCase.fusion index 1cb7a12197b..ea6596c38e7 100644 --- a/Neos.Neos/Resources/Private/Fusion/RootCase.fusion +++ b/Neos.Neos/Resources/Private/Fusion/RootCase.fusion @@ -30,9 +30,9 @@ root { documentType { @position = 'end 9998' condition = Neos.Fusion:CanRender { - type = ${documentNode.nodeType.name} + type = ${documentNode.nodeTypeName.value} } - type = ${documentNode.nodeType.name} + type = ${documentNode.nodeTypeName.value} } default { @@ -53,7 +53,7 @@ root { error { @position = 'end 10001' condition = true - type = ${documentNode.nodeType.name} + type = ${documentNode.nodeTypeName.value} } @cache { diff --git a/Neos.NodeTypes.Navigation/Resources/Private/Fusion/Root.fusion b/Neos.NodeTypes.Navigation/Resources/Private/Fusion/Root.fusion index 4b6b91414fd..b4c1a4b2e40 100644 --- a/Neos.NodeTypes.Navigation/Resources/Private/Fusion/Root.fusion +++ b/Neos.NodeTypes.Navigation/Resources/Private/Fusion/Root.fusion @@ -12,7 +12,7 @@ prototype(Neos.NodeTypes.Navigation:Navigation) < prototype(Neos.Neos:Menu) { maximumLevels = ${q(node).property('maximumLevels')} maximumLevels.@process.1 = ${String.toInteger(value)} - attributes.class.@process.nodeType = ${Array.push(value, String.toLowerCase(String.pregReplace(node.nodeType.name, '/[[:^alnum:]]/', '-')))} + attributes.class.@process.nodeType = ${Array.push(value, String.toLowerCase(String.pregReplace(node.nodeTypeName.value, '/[[:^alnum:]]/', '-')))} active.attributes = Neos.Fusion:Attributes { class = 'active' From 98fa454dc37a53f8084d825ba2e2a3bba337f684 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Fri, 29 Sep 2023 14:27:29 +0200 Subject: [PATCH 25/26] TASK: Adjust to removed `NodeType::getName` --- .../Resources/Private/Fusion/Prototypes/ContentCase.fusion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Neos.Neos/Resources/Private/Fusion/Prototypes/ContentCase.fusion b/Neos.Neos/Resources/Private/Fusion/Prototypes/ContentCase.fusion index cc1544d9301..79bce3f566e 100644 --- a/Neos.Neos/Resources/Private/Fusion/Prototypes/ContentCase.fusion +++ b/Neos.Neos/Resources/Private/Fusion/Prototypes/ContentCase.fusion @@ -6,6 +6,6 @@ prototype(Neos.Neos:ContentCase) < prototype(Neos.Fusion:Case) { default { @position = 'end' condition = true - type = ${Neos.Node.getNodeType(node).name} + type = ${Neos.Node.getNodeType(node).name.value} } } From 2d3bc0aaa7c270b18af3f9b1247a1972ea786044 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Fri, 29 Sep 2023 16:22:34 +0200 Subject: [PATCH 26/26] TASK: Adjust fluid template to removed `NodeType::getName` --- Neos.Neos/Resources/Private/Templates/Service/Nodes/Index.html | 2 +- Neos.Neos/Resources/Private/Templates/Service/Nodes/Show.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Neos.Neos/Resources/Private/Templates/Service/Nodes/Index.html b/Neos.Neos/Resources/Private/Templates/Service/Nodes/Index.html index 95b517807d9..7f112b3b14a 100644 --- a/Neos.Neos/Resources/Private/Templates/Service/Nodes/Index.html +++ b/Neos.Neos/Resources/Private/Templates/Service/Nodes/Index.html @@ -27,7 +27,7 @@

{neos:backend.translate(id: 'service.nodes.title', value: 'Nodes')}

({node.nodeAggregateId.value}) - [{node.nodeType.name}] + [{node.nodeTypeName.value}] {neos:backend.translate(id: 'service.nodes.show', value: 'Show')} diff --git a/Neos.Neos/Resources/Private/Templates/Service/Nodes/Show.html b/Neos.Neos/Resources/Private/Templates/Service/Nodes/Show.html index 34f2ff8a711..7c1f2816b76 100644 --- a/Neos.Neos/Resources/Private/Templates/Service/Nodes/Show.html +++ b/Neos.Neos/Resources/Private/Templates/Service/Nodes/Show.html @@ -25,7 +25,7 @@

{neos:backend.translate(id: 'node', value: 'Node')}: {node.label}

_type - {node.nodeType.name} + {node.nodeTypeName.value}