diff --git a/Neos.Neos/Classes/Controller/Backend/ContentController.php b/Neos.Neos/Classes/Controller/Backend/ContentController.php index 699acb726cc..f03dbbbd620 100644 --- a/Neos.Neos/Classes/Controller/Backend/ContentController.php +++ b/Neos.Neos/Classes/Controller/Backend/ContentController.php @@ -16,6 +16,7 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints; +use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress; use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Flow\Mvc\Controller\ActionController; @@ -38,8 +39,6 @@ use Neos\Media\TypeConverter\AssetInterfaceConverter; use Neos\Media\TypeConverter\ImageInterfaceArrayPresenter; use Neos\Neos\Controller\BackendUserTranslationTrait; -use Neos\Neos\FrontendRouting\NodeAddressFactory; -use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult; use Neos\Neos\TypeConverter\EntityToIdentityConverter; use Neos\Neos\Utility\NodeTypeWithFallbackProvider; @@ -146,13 +145,9 @@ public function initializeUploadAssetAction(): void */ public function uploadAssetAction(Asset $asset, string $metadata, string $node, string $propertyName) { - $nodeAddressString = $node; - $contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest()) - ->contentRepositoryId; - $contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId); - // todo legacy uri node address notation used. Should be refactored to use json encoded NodeAddress - $nodeAddress = NodeAddressFactory::create($contentRepository)->createCoreNodeAddressFromLegacyUriString($nodeAddressString); + $nodeAddress = NodeAddress::fromJsonString($node); + $contentRepository = $this->contentRepositoryRegistry->get($nodeAddress->contentRepositoryId); $node = $contentRepository->getContentGraph($nodeAddress->workspaceName) ->getSubgraph( $nodeAddress->dimensionSpacePoint, diff --git a/Neos.Neos/Classes/Controller/Service/NodesController.php b/Neos.Neos/Classes/Controller/Service/NodesController.php index 2e5090b31dc..5b40ce7ddcf 100644 --- a/Neos.Neos/Classes/Controller/Service/NodesController.php +++ b/Neos.Neos/Classes/Controller/Service/NodesController.php @@ -28,8 +28,8 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\SearchTerm\SearchTerm; use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\SearchTerm\SearchTermMatcher; use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate; -use Neos\ContentRepository\Core\Projection\ContentGraph\Nodes; use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints; +use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; @@ -39,7 +39,6 @@ use Neos\FluidAdaptor\View\TemplateView; use Neos\Neos\Controller\BackendUserTranslationTrait; use Neos\Neos\Domain\Service\NodeTypeNameFactory; -use Neos\Neos\FrontendRouting\NodeAddressFactory; use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult; use Neos\Neos\Ui\Domain\Service\NodePropertyConverterService; use Neos\Neos\View\Service\NodeJsonView; @@ -130,9 +129,8 @@ public function indexAction( : null; $nodeAddress = null; if (!$nodePath) { - // todo legacy uri node address notation used. Should be refactored to use json encoded NodeAddress $nodeAddress = $contextNode - ? NodeAddressFactory::create($contentRepository)->createCoreNodeAddressFromLegacyUriString($contextNode) + ? NodeAddress::fromJsonString($contextNode) : null; } @@ -238,7 +236,7 @@ public function showAction(string $identifier, string $workspaceName = 'live', a } }); - $nodeAddress = NodeAddressFactory::create($contentRepository)->createFromNode($node)->serializeForUri(); + $nodeAddress = NodeAddress::fromNode($node)->toJson(); $this->view->assignMultiple([ 'node' => $node, diff --git a/Neos.Neos/Classes/FrontendRouting/NodeAddress.php b/Neos.Neos/Classes/FrontendRouting/NodeAddress.php deleted file mode 100644 index 08e0d85be27..00000000000 --- a/Neos.Neos/Classes/FrontendRouting/NodeAddress.php +++ /dev/null @@ -1,62 +0,0 @@ -workspaceName->value - . '__' . base64_encode(json_encode($this->dimensionSpacePoint->coordinates, JSON_THROW_ON_ERROR)) - . '__' . $this->nodeAggregateId->value; - } - - public function __toString(): string - { - return sprintf( - 'NodeAddress[dimensionSpacePoint=%s, nodeAggregateId=%s, workspaceName=%s]', - $this->dimensionSpacePoint->toJson(), - $this->nodeAggregateId->value, - $this->workspaceName->value - ); - } -} diff --git a/Neos.Neos/Classes/FrontendRouting/NodeAddressFactory.php b/Neos.Neos/Classes/FrontendRouting/NodeAddressFactory.php deleted file mode 100644 index b5169ae51c1..00000000000 --- a/Neos.Neos/Classes/FrontendRouting/NodeAddressFactory.php +++ /dev/null @@ -1,80 +0,0 @@ -dimensionSpacePoint, - $node->aggregateId, - $node->workspaceName, - ); - } - - public function createCoreNodeAddressFromLegacyUriString(string $serializedNodeAddress): NodeAddress - { - $legacy = $this->createFromUriString($serializedNodeAddress); - - return NodeAddress::create( - $this->contentRepository->id, - $legacy->workspaceName, - $legacy->dimensionSpacePoint, - $legacy->nodeAggregateId - ); - } - - public function createFromUriString(string $serializedNodeAddress): LegacyNodeAddress - { - // the reverse method is {@link NodeAddress::serializeForUri} - ensure to adjust it - // when changing the serialization here - - list($workspaceNameSerialized, $dimensionSpacePointSerialized, $nodeAggregateIdSerialized) - = explode('__', $serializedNodeAddress); - $workspaceName = WorkspaceName::fromString($workspaceNameSerialized); - $dimensionSpacePoint = DimensionSpacePoint::fromArray(json_decode(base64_decode($dimensionSpacePointSerialized), true)); - $nodeAggregateId = NodeAggregateId::fromString($nodeAggregateIdSerialized); - - return new LegacyNodeAddress( - null, - $dimensionSpacePoint, - $nodeAggregateId, - $workspaceName - ); - } -} diff --git a/Neos.Neos/Classes/Routing/NodeIdentityConverterAspect.php b/Neos.Neos/Classes/Routing/NodeIdentityConverterAspect.php index 9a4250915ec..477df41ac1c 100644 --- a/Neos.Neos/Classes/Routing/NodeIdentityConverterAspect.php +++ b/Neos.Neos/Classes/Routing/NodeIdentityConverterAspect.php @@ -16,7 +16,6 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress; -use Neos\Neos\FrontendRouting\NodeAddress as LegacyNodeAddress; use Neos\Flow\Annotations as Flow; use Neos\Flow\Aop\JoinPointInterface; @@ -47,8 +46,6 @@ public function convertNodeToContextPathForRouting(JoinPointInterface $joinPoint return ['__contextNodePath' => NodeAddress::fromNode($objectArgument)->toJson()]; } elseif ($objectArgument instanceof NodeAddress) { return ['__contextNodePath' => $objectArgument->toJson()]; - } elseif ($objectArgument instanceof LegacyNodeAddress) { - return ['__contextNodePath' => $objectArgument->serializeForUri()]; } return $joinPoint->getAdviceChain()->proceed($joinPoint); diff --git a/Neos.Neos/Classes/Service/ContentElementEditableService.php b/Neos.Neos/Classes/Service/ContentElementEditableService.php index 4f323d32c26..efbf3d18d73 100644 --- a/Neos.Neos/Classes/Service/ContentElementEditableService.php +++ b/Neos.Neos/Classes/Service/ContentElementEditableService.php @@ -15,11 +15,11 @@ namespace Neos\Neos\Service; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; +use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress; use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Flow\Security\Authorization\PrivilegeManagerInterface; use Neos\Fusion\Service\HtmlAugmenter as FusionHtmlAugmenter; -use Neos\Neos\FrontendRouting\NodeAddressFactory; /** * The content element editable service adds the necessary markup around @@ -61,9 +61,7 @@ public function wrapContentProperty(Node $node, string $property, string $conten $attributes = [ 'data-__neos-property' => $property, - 'data-__neos-editable-node-contextpath' => NodeAddressFactory::create($contentRepository) - ->createFromNode($node) - ->serializeForUri() + 'data-__neos-editable-node-contextpath' => NodeAddress::fromNode($node)->toJson() ]; return $this->htmlAugmenter->addAttributes($content, $attributes, 'span'); diff --git a/Neos.Neos/Classes/Service/ContentElementWrappingService.php b/Neos.Neos/Classes/Service/ContentElementWrappingService.php index 7da3e721dd4..339670a8991 100644 --- a/Neos.Neos/Classes/Service/ContentElementWrappingService.php +++ b/Neos.Neos/Classes/Service/ContentElementWrappingService.php @@ -15,10 +15,10 @@ namespace Neos\Neos\Service; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; +use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress; use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Fusion\Service\HtmlAugmenter as FusionHtmlAugmenter; -use Neos\Neos\FrontendRouting\NodeAddressFactory; /** * The content element wrapping service adds the necessary markup around @@ -62,10 +62,10 @@ public function wrapContentObject( //} - $nodeAddress = NodeAddressFactory::create($contentRepository)->createFromNode($node); + $nodeAddress = NodeAddress::fromNode($node); $attributes = $additionalAttributes; $attributes['data-__neos-fusion-path'] = $fusionPath; - $attributes['data-__neos-node-contextpath'] = $nodeAddress->serializeForUri(); + $attributes['data-__neos-node-contextpath'] = $nodeAddress->toJson(); // Define all attribute names as exclusive via the `exclusiveAttributes` parameter, to prevent the data of // two different nodes to be concatenated into the attributes of a single html node. diff --git a/Neos.Neos/Classes/Service/Controller/DataSourceController.php b/Neos.Neos/Classes/Service/Controller/DataSourceController.php index d77001d437a..db29b994b7b 100644 --- a/Neos.Neos/Classes/Service/Controller/DataSourceController.php +++ b/Neos.Neos/Classes/Service/Controller/DataSourceController.php @@ -21,12 +21,10 @@ use Neos\Flow\Annotations as Flow; use Neos\Flow\Mvc\View\JsonView; use Neos\Flow\ObjectManagement\ObjectManagerInterface; -use Neos\Neos\FrontendRouting\NodeAddressFactory; -use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult; -use Neos\Utility\ObjectAccess; use Neos\Flow\Reflection\ReflectionService; use Neos\Neos\Exception as NeosException; use Neos\Neos\Service\DataSource\DataSourceInterface; +use Neos\Utility\ObjectAccess; /** * Data Source Controller @@ -81,12 +79,9 @@ private function deserializeNodeFromLegacyAddress(?string $stringFormattedNodeAd return null; } - $contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest()) - ->contentRepositoryId; - $contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId); - // todo legacy uri node address notation used. Should be refactored to use json encoded NodeAddress - $nodeAddress = NodeAddressFactory::create($contentRepository)->createCoreNodeAddressFromLegacyUriString($stringFormattedNodeAddress); + $nodeAddress = NodeAddress::fromJsonString($stringFormattedNodeAddress); + $contentRepository = $this->contentRepositoryRegistry->get($nodeAddress->contentRepositoryId); return $contentRepository->getContentGraph($nodeAddress->workspaceName)->getSubgraph( $nodeAddress->dimensionSpacePoint, VisibilityConstraints::withoutRestrictions() diff --git a/Neos.Neos/Classes/TypeConverter/NodeAddressToStringConverter.php b/Neos.Neos/Classes/TypeConverter/NodeAddressToStringConverter.php index c56bc511104..32f47c277ca 100644 --- a/Neos.Neos/Classes/TypeConverter/NodeAddressToStringConverter.php +++ b/Neos.Neos/Classes/TypeConverter/NodeAddressToStringConverter.php @@ -14,10 +14,10 @@ namespace Neos\Neos\TypeConverter; +use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress; use Neos\Flow\Annotations as Flow; use Neos\Flow\Property\PropertyMappingConfigurationInterface; use Neos\Flow\Property\TypeConverter\AbstractTypeConverter; -use Neos\Neos\FrontendRouting\NodeAddress; /** * An Object Converter for Node Addresses which can be used for routing (but also for other @@ -53,6 +53,6 @@ public function convertFrom( array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null ): string { - return $source->serializeForUri(); + return $source->toJson(); } } diff --git a/Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php b/Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php index c5710e14cfb..598da056b9d 100644 --- a/Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php +++ b/Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php @@ -59,8 +59,6 @@ use Neos\Neos\Domain\Service\UserService; use Neos\Neos\Domain\Service\WorkspacePublishingService; use Neos\Neos\Domain\Service\WorkspaceService; -use Neos\Neos\FrontendRouting\NodeAddress as LegacyNodeAddress; -use Neos\Neos\FrontendRouting\NodeAddressFactory; use Neos\Neos\FrontendRouting\NodeUriBuilderFactory; use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult; use Neos\Neos\PendingChangesProjection\ChangeFinder; @@ -424,17 +422,13 @@ public function deleteAction(WorkspaceName $workspaceName): void */ public function rebaseAndRedirectAction(string $targetNode, Workspace $targetWorkspace): void { - $contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest()) - ->contentRepositoryId; - $contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId); - // todo legacy uri node address notation used. Should be refactored to use json encoded NodeAddress - $targetNodeAddress = NodeAddressFactory::create($contentRepository)->createCoreNodeAddressFromLegacyUriString($targetNode); + $targetNodeAddress = NodeAddress::fromJsonString($targetNode); $user = $this->userService->getCurrentUser(); if ($user === null) { throw new \RuntimeException('No account is authenticated', 1710068880); } - $personalWorkspace = $this->workspaceService->getPersonalWorkspaceForUser($contentRepositoryId, $user->getId()); + $personalWorkspace = $this->workspaceService->getPersonalWorkspaceForUser($targetNodeAddress->contentRepositoryId, $user->getId()); /** @todo do something else * if ($personalWorkspace !== $targetWorkspace) { @@ -463,13 +457,6 @@ public function rebaseAndRedirectAction(string $targetNode, Workspace $targetWor ); if ($this->packageManager->isPackageAvailable('Neos.Neos.Ui')) { - // todo remove me legacy - $legacyTargetNodeAddressInPersonalWorkspace = new LegacyNodeAddress( - null, - $targetNodeAddressInPersonalWorkspace->dimensionSpacePoint, - $targetNodeAddressInPersonalWorkspace->aggregateId, - $targetNodeAddressInPersonalWorkspace->workspaceName - ); $mainRequest = $this->controllerContext->getRequest()->getMainRequest(); $this->uriBuilder->setRequest($mainRequest); @@ -477,7 +464,7 @@ public function rebaseAndRedirectAction(string $targetNode, Workspace $targetWor 'index', 'Backend', 'Neos.Neos.Ui', - ['node' => $legacyTargetNodeAddressInPersonalWorkspace] + ['node' => $targetNodeAddressInPersonalWorkspace->toJson()] ); } @@ -495,12 +482,9 @@ public function rebaseAndRedirectAction(string $targetNode, Workspace $targetWor */ public function publishNodeAction(string $nodeAddress, WorkspaceName $selectedWorkspace): void { - $contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest()) - ->contentRepositoryId; - $contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId); - $nodeAddressFactory = NodeAddressFactory::create($contentRepository); - // todo legacy uri node address notation used. Should be refactored to use json encoded NodeAddress - $nodeAddress = $nodeAddressFactory->createCoreNodeAddressFromLegacyUriString($nodeAddress); + $nodeAddress = NodeAddress::fromJsonString($nodeAddress); + + $contentRepository = $this->contentRepositoryRegistry->get($nodeAddress->contentRepositoryId); $command = PublishIndividualNodesFromWorkspace::create( $selectedWorkspace, @@ -511,8 +495,7 @@ public function publishNodeAction(string $nodeAddress, WorkspaceName $selectedWo ) ), ); - $contentRepository->handle($command) - ; + $contentRepository->handle($command); $this->addFlashMessage($this->translator->translateById( 'workspaces.selectedChangeHasBeenPublished', @@ -533,12 +516,9 @@ public function publishNodeAction(string $nodeAddress, WorkspaceName $selectedWo */ public function discardNodeAction(string $nodeAddress, WorkspaceName $selectedWorkspace): void { - $contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest()) - ->contentRepositoryId; - $contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId); - $nodeAddressFactory = NodeAddressFactory::create($contentRepository); - // todo legacy uri node address notation used. Should be refactored to use json encoded NodeAddress - $nodeAddress = $nodeAddressFactory->createCoreNodeAddressFromLegacyUriString($nodeAddress); + $nodeAddress = NodeAddress::fromJsonString($nodeAddress); + + $contentRepository = $this->contentRepositoryRegistry->get($nodeAddress->contentRepositoryId); $command = DiscardIndividualNodesFromWorkspace::create( $selectedWorkspace, @@ -549,8 +529,7 @@ public function discardNodeAction(string $nodeAddress, WorkspaceName $selectedWo ) ), ); - $contentRepository->handle($command) - ; + $contentRepository->handle($command); $this->addFlashMessage($this->translator->translateById( 'workspaces.selectedChangeHasBeenDiscarded', @@ -575,12 +554,10 @@ public function publishOrDiscardNodesAction(array $nodes, string $action, string $contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest()) ->contentRepositoryId; $contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId); - $nodeAddressFactory = NodeAddressFactory::create($contentRepository); $nodesToPublishOrDiscard = []; foreach ($nodes as $node) { - // todo legacy uri node address notation used. Should be refactored to use json encoded NodeAddress - $nodeAddress = $nodeAddressFactory->createCoreNodeAddressFromLegacyUriString($node); + $nodeAddress = NodeAddress::fromJsonString($node); $nodesToPublishOrDiscard[] = new NodeIdToPublishOrDiscard( $nodeAddress->aggregateId, $nodeAddress->dimensionSpacePoint @@ -782,19 +759,19 @@ protected function computeSiteChanges(Workspace $selectedWorkspace, ContentRepos $siteChanges[$siteNodeName]['documents'][$documentPath]['isMoved'] = $change->moved; } - // As for changes of type `delete` we are using nodes from the live content stream - // we can't create `serializedNodeAddress` from the node. + // As for changes of type `delete` we are using nodes from the live workspace + // we can't create a serialized nodeAddress from the node. // Instead, we use the original stored values. - $nodeAddress = new LegacyNodeAddress( - null, + $nodeAddress = NodeAddress::create( + $contentRepository->id, + $selectedWorkspace->workspaceName, $change->originDimensionSpacePoint->toDimensionSpacePoint(), - $change->nodeAggregateId, - $selectedWorkspace->workspaceName + $change->nodeAggregateId ); $change = [ 'node' => $node, - 'serializedNodeAddress' => $nodeAddress->serializeForUri(), + 'serializedNodeAddress' => $nodeAddress->toJson(), 'isRemoved' => $change->deleted, 'isNew' => $change->created, 'isMoved' => $change->moved,