diff --git a/Classes/ContentRepository/Service/NodeService.php b/Classes/ContentRepository/Service/NodeService.php index afecaf9cd0..cad0b5c744 100644 --- a/Classes/ContentRepository/Service/NodeService.php +++ b/Classes/ContentRepository/Service/NodeService.php @@ -18,31 +18,31 @@ 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 NodeService { - /** - * @Flow\Inject - * @var ContentRepositoryRegistry - */ - protected $contentRepositoryRegistry; + use NodeTypeWithFallbackProvider; + + #[Flow\Inject] + protected ContentRepositoryRegistry $contentRepositoryRegistry; /** * Helper method to retrieve the closest document for a node */ public function getClosestDocument(Node $node): ?Node { - if ($node->nodeType->isOfType('Neos.Neos:Document')) { + if ($this->getNodeType($node)->isOfType('Neos.Neos:Document')) { return $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 = $subgraph->findParentNode($node->nodeAggregateId); diff --git a/Classes/ContentRepository/Service/WorkspaceService.php b/Classes/ContentRepository/Service/WorkspaceService.php index a66162966e..9ae80ff464 100644 --- a/Classes/ContentRepository/Service/WorkspaceService.php +++ b/Classes/ContentRepository/Service/WorkspaceService.php @@ -26,12 +26,18 @@ use Neos\Neos\PendingChangesProjection\ChangeFinder; use Neos\Neos\Service\UserService; use Neos\Neos\Ui\Domain\Model\Feedback\Operations\RemoveNode; +use Neos\Neos\Utility\NodeTypeWithFallbackProvider; /** * @Flow\Scope("singleton") */ class WorkspaceService { + use NodeTypeWithFallbackProvider; + + #[Flow\Inject] + protected ContentRepositoryRegistry $contentRepositoryRegistry; + /** * @Flow\Inject * @var UserService @@ -44,12 +50,6 @@ class WorkspaceService */ protected $domainUserService; - /** - * @Flow\Inject - * @var ContentRepositoryRegistry - */ - protected $contentRepositoryRegistry; - /** * Get all publishable node context paths for a workspace * @@ -207,7 +207,7 @@ private function getClosestDocumentNode(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 = $subgraph->findParentNode($node->nodeAggregateId); diff --git a/Classes/Domain/Model/AbstractChange.php b/Classes/Domain/Model/AbstractChange.php index 5761289f45..9edfac63f3 100644 --- a/Classes/Domain/Model/AbstractChange.php +++ b/Classes/Domain/Model/AbstractChange.php @@ -19,11 +19,17 @@ use Neos\Neos\Ui\Domain\Model\Feedback\Operations\NodeCreated; use Neos\Neos\Ui\Domain\Model\Feedback\Operations\ReloadDocument; use Neos\Neos\Ui\Domain\Model\Feedback\Operations\UpdateWorkspaceInfo; +use Neos\Neos\Utility\NodeTypeWithFallbackProvider; abstract class AbstractChange implements ChangeInterface { + use NodeTypeWithFallbackProvider; + protected ?Node $subject; + #[Flow\Inject] + protected ContentRepositoryRegistry $contentRepositoryRegistry; + /** * @Flow\Inject * @var FeedbackCollection @@ -42,12 +48,6 @@ abstract class AbstractChange implements ChangeInterface */ protected $persistenceManager; - /** - * @Flow\Inject - * @var ContentRepositoryRegistry - */ - protected $contentRepositoryRegistry; - public function setSubject(Node $subject): void { $this->subject = $subject; @@ -81,7 +81,7 @@ protected function updateWorkspaceInfo(): void final protected function findClosestDocumentNode(Node $node): ?Node { while ($node instanceof Node) { - if ($node->nodeType->isOfType('Neos.Neos:Document')) { + if ($this->getNodeType($node)->isOfType('Neos.Neos:Document')) { return $node; } $node = $this->findParentNode($node); diff --git a/Classes/Domain/Model/Changes/AbstractStructuralChange.php b/Classes/Domain/Model/Changes/AbstractStructuralChange.php index b1a18ad614..f4eb59d5a1 100644 --- a/Classes/Domain/Model/Changes/AbstractStructuralChange.php +++ b/Classes/Domain/Model/Changes/AbstractStructuralChange.php @@ -26,12 +26,18 @@ use Neos\Neos\Ui\Domain\Model\Feedback\Operations\RenderContentOutOfBand; use Neos\Neos\Ui\Domain\Model\Feedback\Operations\UpdateNodeInfo; use Neos\Neos\Ui\Domain\Model\RenderedNodeDomAddress; +use Neos\Neos\Utility\NodeTypeWithFallbackProvider; /** * A change that performs structural actions like moving or creating nodes */ abstract class AbstractStructuralChange extends AbstractChange { + use NodeTypeWithFallbackProvider; + + #[Flow\Inject] + protected ContentRepositoryRegistry $contentRepositoryRegistry; + /** * The node dom address for the parent node of the created node */ @@ -48,12 +54,6 @@ abstract class AbstractStructuralChange extends AbstractChange */ protected $nodeService; - /** - * @Flow\Inject - * @var ContentRepositoryRegistry - */ - protected $contentRepositoryRegistry; - protected ?Node $cachedSiblingNode = null; /** @@ -146,14 +146,14 @@ protected function finish(Node $node) $this->updateWorkspaceInfo(); - if ($node->nodeType->isOfType('Neos.Neos:Content') + if ($this->getNodeType($node)->isOfType('Neos.Neos:Content') && ($this->getParentDomAddress() || $this->getSiblingDomAddress())) { // we can ONLY render out of band if: // 1) the parent of our new (or copied or moved) node is a ContentCollection; // so we can directly update an element of this content collection $contentRepository = $this->contentRepositoryRegistry->get($parentNode->subgraphIdentity->contentRepositoryId); - if ($parentNode && $parentNode->nodeType->isOfType('Neos.Neos:ContentCollection') && + if ($parentNode && $this->getNodeType($parentNode)->isOfType('Neos.Neos:ContentCollection') && // 2) the parent DOM address (i.e. the closest RENDERED node in DOM is actually the ContentCollection; // and no other node in between $this->getParentDomAddress() && @@ -189,12 +189,12 @@ protected function isNodeTypeAllowedAsChildNode(Node $node, NodeType $nodeType): $subgraph = $this->contentRepositoryRegistry->subgraphForNode($node); if ($node->classification === NodeAggregateClassification::CLASSIFICATION_TETHERED) { $parentNode = $subgraph->findParentNode($node->nodeAggregateId); - return !$parentNode || $parentNode->nodeType->allowsGrandchildNodeType( + return !$parentNode || $this->getNodeType($parentNode)->allowsGrandchildNodeType( $node->nodeName->value, $nodeType ); } else { - return $node->nodeType->allowsChildNodeType($nodeType); + return $this->getNodeType($node)->allowsChildNodeType($nodeType); } } } diff --git a/Classes/Domain/Model/Changes/Property.php b/Classes/Domain/Model/Changes/Property.php index 86985767bd..2afbc0687b 100644 --- a/Classes/Domain/Model/Changes/Property.php +++ b/Classes/Domain/Model/Changes/Property.php @@ -29,12 +29,14 @@ use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateIds; use Neos\ContentRepository\Core\SharedModel\Node\NodeVariantSelectionStrategy; use Neos\ContentRepository\Core\SharedModel\Node\ReferenceName; +use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Neos\Ui\Domain\Model\AbstractChange; use Neos\Neos\Ui\Domain\Model\Feedback\Operations\ReloadContentOutOfBand; use Neos\Neos\Ui\Domain\Model\Feedback\Operations\UpdateNodeInfo; use Neos\Neos\Ui\Domain\Model\RenderedNodeDomAddress; use Neos\Neos\Ui\Domain\Service\NodePropertyConversionService; +use Neos\Neos\Utility\NodeTypeWithFallbackProvider; /** @codingStandardsIgnoreStart */ /** @codingStandardsIgnoreEnd */ @@ -44,6 +46,11 @@ */ class Property extends AbstractChange { + use NodeTypeWithFallbackProvider; + + #[Flow\Inject] + protected ContentRepositoryRegistry $contentRepositoryRegistry; + /** * @Flow\Inject * @var NodePropertyConversionService @@ -147,7 +154,7 @@ public function apply(): void if ($this->canApply() && !is_null($subject) && !is_null($propertyName)) { $contentRepository = $this->contentRepositoryRegistry->get($subject->subgraphIdentity->contentRepositoryId); - $propertyType = $subject->nodeType->getPropertyType($propertyName); + $propertyType = $this->getNodeType($subject)->getPropertyType($propertyName); // Use extra commands for reference handling if ($propertyType === 'reference' || $propertyType === 'references') { @@ -180,7 +187,7 @@ public function apply(): void ); } else { $value = $this->nodePropertyConversionService->convert( - $subject->nodeType, + $this->getNodeType($subject), $propertyName, $this->getValue() ); @@ -273,10 +280,10 @@ public function apply(): void $this->feedbackCollection->add($updateNodeInfo); $reloadIfChangedConfigurationPath = sprintf('properties.%s.ui.reloadIfChanged', $propertyName); - if (!$this->getIsInline() && $node->nodeType->getConfiguration($reloadIfChangedConfigurationPath)) { + if (!$this->getIsInline() && $this->getNodeType($node)->getConfiguration($reloadIfChangedConfigurationPath)) { if ($this->getNodeDomAddress() && $this->getNodeDomAddress()->getFusionPath() && $parentNode - && $parentNode->nodeType->isOfType('Neos.Neos:ContentCollection')) { + && $this->getNodeType($parentNode)->isOfType('Neos.Neos:ContentCollection')) { $reloadContentOutOfBand = new ReloadContentOutOfBand(); $reloadContentOutOfBand->setNode($node); $reloadContentOutOfBand->setNodeDomAddress($this->getNodeDomAddress()); @@ -288,7 +295,7 @@ public function apply(): void $reloadPageIfChangedConfigurationPath = sprintf('properties.%s.ui.reloadPageIfChanged', $propertyName); if (!$this->getIsInline() - && $node->nodeType->getConfiguration($reloadPageIfChangedConfigurationPath)) { + && $this->getNodeType($node)->getConfiguration($reloadPageIfChangedConfigurationPath)) { $this->reloadDocument($node); } } diff --git a/Classes/Domain/Model/Feedback/Operations/NodeCreated.php b/Classes/Domain/Model/Feedback/Operations/NodeCreated.php index bbd8a4bcfd..cf76c19a25 100644 --- a/Classes/Domain/Model/Feedback/Operations/NodeCreated.php +++ b/Classes/Domain/Model/Feedback/Operations/NodeCreated.php @@ -19,20 +19,20 @@ use Neos\Neos\Domain\Service\NodeTypeNameFactory; use Neos\Neos\Ui\Domain\Model\AbstractFeedback; use Neos\Neos\Ui\Domain\Model\FeedbackInterface; +use Neos\Neos\Utility\NodeTypeWithFallbackProvider; class NodeCreated extends AbstractFeedback { + use NodeTypeWithFallbackProvider; + + #[Flow\Inject] + protected ContentRepositoryRegistry $contentRepositoryRegistry; + /** * @var Node */ protected $node; - /** - * @Flow\Inject - * @var ContentRepositoryRegistry - */ - protected $contentRepositoryRegistry; - /** * Set the node */ @@ -97,7 +97,7 @@ public function serializePayload(ControllerContext $controllerContext) return [ 'contextPath' => $nodeAddressFactory->createFromNode($node)->serializeForUri(), 'identifier' => $node->nodeAggregateId->value, - 'isDocument' => $node->nodeType->isOfType(NodeTypeNameFactory::NAME_DOCUMENT) + 'isDocument' => $this->getNodeType($node)->isOfType(NodeTypeNameFactory::NAME_DOCUMENT) ]; } } diff --git a/Classes/Domain/Service/NodePropertyConverterService.php b/Classes/Domain/Service/NodePropertyConverterService.php index 90a71e41dd..ad098a8ad0 100644 --- a/Classes/Domain/Service/NodePropertyConverterService.php +++ b/Classes/Domain/Service/NodePropertyConverterService.php @@ -17,7 +17,6 @@ use Neos\ContentRepository\Core\NodeType\NodeType; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindReferencesFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; -use Neos\ContentRepository\Core\Projection\ContentGraph\Reference; use Neos\ContentRepository\Core\Projection\ContentGraph\References; use Neos\ContentRepository\Core\Projection\NodeHiddenState\NodeHiddenStateFinder; use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; @@ -30,6 +29,7 @@ use Neos\Flow\Property\PropertyMappingConfiguration; use Neos\Flow\Property\PropertyMappingConfigurationInterface; use Neos\Flow\Property\TypeConverterInterface; +use Neos\Neos\Utility\NodeTypeWithFallbackProvider; use Neos\Utility\ObjectAccess; use Neos\Utility\TypeHandling; use Psr\Log\LoggerInterface; @@ -44,6 +44,11 @@ */ class NodePropertyConverterService { + use NodeTypeWithFallbackProvider; + + #[Flow\Inject] + protected ContentRepositoryRegistry $contentRepositoryRegistry; + /** * @Flow\InjectConfiguration(package="Neos.Neos", path="userInterface.inspector.dataTypes") * @var array> @@ -78,12 +83,6 @@ class NodePropertyConverterService */ private $throwableStorage; - /** - * @Flow\Inject - * @var ContentRepositoryRegistry - */ - protected $contentRepositoryRegistry; - /** * @param LoggerInterface $logger */ @@ -119,7 +118,7 @@ public function getProperty(Node $node, $propertyName) $node->nodeAggregateId )->isHidden; } - $propertyType = $node->nodeType->getPropertyType($propertyName); + $propertyType = $this->getNodeType($node)->getPropertyType($propertyName); // We handle "reference" and "references" differently than other properties; // because we need to use another API for querying these references. @@ -160,7 +159,7 @@ public function getProperty(Node $node, $propertyName) } if ($convertedValue === null) { - $convertedValue = $this->getDefaultValueForProperty($node->nodeType, $propertyName); + $convertedValue = $this->getDefaultValueForProperty($this->getNodeType($node), $propertyName); if ($convertedValue !== null) { try { $convertedValue = $this->convertValue($convertedValue, $propertyType); @@ -196,7 +195,7 @@ private function toNodeIdentifierStrings(References $references): array public function getPropertiesArray(Node $node) { $properties = []; - foreach ($node->nodeType->getProperties() as $propertyName => $propertyConfiguration) { + foreach ($this->getNodeType($node)->getProperties() as $propertyName => $propertyConfiguration) { if ($propertyName[0] === '_' && $propertyName[1] === '_') { // skip fully-private properties continue; diff --git a/Classes/Fusion/Helper/NodeInfoHelper.php b/Classes/Fusion/Helper/NodeInfoHelper.php index 5635574cfd..62abda3f3c 100644 --- a/Classes/Fusion/Helper/NodeInfoHelper.php +++ b/Classes/Fusion/Helper/NodeInfoHelper.php @@ -30,12 +30,18 @@ use Neos\Neos\Ui\Domain\Service\NodePropertyConverterService; use Neos\Neos\Ui\Domain\Service\UserLocaleService; use Neos\Neos\Ui\Service\NodePolicyService; +use Neos\Neos\Utility\NodeTypeWithFallbackProvider; /** * @Flow\Scope("singleton") */ class NodeInfoHelper implements ProtectedContextAwareInterface { + use NodeTypeWithFallbackProvider; + + #[Flow\Inject] + protected ContentRepositoryRegistry $contentRepositoryRegistry; + /** * @Flow\Inject * @var NodePolicyService @@ -48,12 +54,6 @@ class NodeInfoHelper implements ProtectedContextAwareInterface */ protected $userLocaleService; - /** - * @Flow\Inject - * @var ContentRepositoryRegistry - */ - protected $contentRepositoryRegistry; - /** * @Flow\Inject * @var EntityToIdentityConverter @@ -209,7 +209,7 @@ public function renderNodeWithPropertiesAndChildrenInformation( protected function getUriInformation(Node $node, ControllerContext $controllerContext): array { $nodeInfo = []; - if (!$node->nodeType->isOfType($this->documentNodeTypeRole)) { + if (!$this->getNodeType($node)->isOfType($this->documentNodeTypeRole)) { return $nodeInfo; } $nodeInfo['uri'] = $this->previewUri($node, $controllerContext); @@ -342,7 +342,7 @@ public function renderNodesWithParents(array $nodes, ControllerContext $controll continue; } - while ($parentNode->nodeType->isOfType($baseNodeTypeOverride)) { + while ($this->getNodeType($parentNode)->isOfType($baseNodeTypeOverride)) { if (array_key_exists($parentNode->nodeAggregateId->value, $renderedNodes)) { $renderedNodes[$parentNode->nodeAggregateId->value]['intermediate'] = true; } else { diff --git a/Classes/Service/NodePolicyService.php b/Classes/Service/NodePolicyService.php index b31c8dc6b4..5f95a48d1d 100644 --- a/Classes/Service/NodePolicyService.php +++ b/Classes/Service/NodePolicyService.php @@ -27,24 +27,24 @@ use Neos\Flow\Security\Authorization\PrivilegeManagerInterface; use Neos\Flow\Security\Policy\PolicyService; use Neos\Neos\Security\Authorization\Privilege\NodeTreePrivilege; +use Neos\Neos\Utility\NodeTypeWithFallbackProvider; /** * @Flow\Scope("singleton") */ class NodePolicyService { + use NodeTypeWithFallbackProvider; + + #[Flow\Inject] + protected ContentRepositoryRegistry $contentRepositoryRegistry; + /** * @Flow\Inject * @var PrivilegeManagerInterface */ protected $privilegeManager; - /** - * @Flow\Inject - * @var ContentRepositoryRegistry - */ - protected $contentRepositoryRegistry; - /** * @Flow\Inject * @var ObjectManagerInterface @@ -183,7 +183,7 @@ public function getDisallowedProperties(Node $node): array ); }; - $disallowedProperties = array_filter(array_keys($node->nodeType->getProperties()), $filter); + $disallowedProperties = array_filter(array_keys($this->getNodeType($node)->getProperties()), $filter); return $disallowedProperties; } }