Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: migrate to new json node address #3858

Merged
merged 5 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Classes/Application/ChangeTargetWorkspace.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
namespace Neos\Neos\Ui\Application;

use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\FrontendRouting\NodeAddress;

/**
* The application layer level command DTO to communicate the change of the selected target workspace for publication
Expand Down
2 changes: 0 additions & 2 deletions Classes/Application/ReloadNodes/NodeMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@

namespace Neos\Neos\Ui\Application\ReloadNodes;

use Neos\ContentRepository\Core\ContentRepository;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Neos\FrontendRouting\NodeAddress;
use Neos\Neos\Ui\Fusion\Helper\NodeInfoHelper;

/**
Expand Down
6 changes: 2 additions & 4 deletions Classes/Application/ReloadNodes/ReloadNodesQueryHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\NodeTypeCriteria;
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\ActionRequest;
use Neos\Neos\Domain\Service\NodeTypeNameFactory;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\Neos\Ui\Fusion\Helper\NodeInfoHelper;

/**
Expand Down Expand Up @@ -148,10 +148,8 @@ public function handle(ReloadNodesQuery $query, ActionRequest $actionRequest): R
- but the logic above mirrors the old behavior better.
https://github.com/neos/neos-ui/issues/3517#issuecomment-2070274053 */

$nodeAddressFactory = NodeAddressFactory::create($contentRepository);

return new ReloadNodesQueryResult(
documentId: $nodeAddressFactory->createFromNode($documentNode),
documentId: NodeAddress::fromNode($documentNode),
nodes: $nodeMapBuilder->build()
);
}
Expand Down
4 changes: 2 additions & 2 deletions Classes/Application/ReloadNodes/ReloadNodesQueryResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

namespace Neos\Neos\Ui\Application\ReloadNodes;

use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\FrontendRouting\NodeAddress;

/**
* The application layer level query result containing all nodes the UI needs
Expand All @@ -38,7 +38,7 @@ public function __construct(
public function jsonSerialize(): array
{
return [
'documentId' => $this->documentId->serializeForUri(),
'documentId' => $this->documentId->toJson(),
'nodes' => $this->nodes
];
}
Expand Down
21 changes: 5 additions & 16 deletions Classes/ContentRepository/Service/NeosUiNodeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,30 @@
*/


use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
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\Neos\FrontendRouting\NodeAddress;
use Neos\Neos\Utility\NodeTypeWithFallbackProvider;

/**
* @internal
* @Flow\Scope("singleton")
*/
class NeosUiNodeService
{
use NodeTypeWithFallbackProvider;

#[Flow\Inject]
protected ContentRepositoryRegistry $contentRepositoryRegistry;

public function findNodeBySerializedNodeAddress(string $serializedNodeAddress, ContentRepositoryId $contentRepositoryId): ?Node
public function findNodeBySerializedNodeAddress(string $serializedNodeAddress): ?Node
{
$contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId);
$nodeAddress = NodeAddressFactory::create($contentRepository)->createFromUriString($serializedNodeAddress);
$nodeAddress = NodeAddress::fromJsonString($serializedNodeAddress);
$contentRepository = $this->contentRepositoryRegistry->get($nodeAddress->contentRepositoryId);

$subgraph = $contentRepository->getContentGraph($nodeAddress->workspaceName)->getSubgraph(
$nodeAddress->dimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
);
return $subgraph->findNodeById($nodeAddress->nodeAggregateId);
}

public function deserializeNodeAddress(string $serializedNodeAddress, ContentRepositoryId $contentRepositoryId): NodeAddress
{
$contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId);
return NodeAddressFactory::create($contentRepository)->createFromUriString($serializedNodeAddress);
return $subgraph->findNodeById($nodeAddress->aggregateId);
}
}
29 changes: 13 additions & 16 deletions Classes/ContentRepository/Service/WorkspaceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindClosestNodeFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\Domain\Service\NodeTypeNameFactory;
use Neos\Neos\Domain\Service\WorkspacePublishingService;
use Neos\Neos\FrontendRouting\NodeAddress;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\Neos\PendingChangesProjection\Change;
use Neos\Neos\Utility\NodeTypeWithFallbackProvider;

Expand Down Expand Up @@ -57,26 +56,26 @@ public function getPublishableNodeInfo(WorkspaceName $workspaceName, ContentRepo
$unpublishedNodes = [];
foreach ($pendingChanges as $change) {
if ($change->removalAttachmentPoint) {
$nodeAddress = new NodeAddress(
$change->contentStreamId,
$nodeAddress = NodeAddress::create(
$contentRepositoryId,
$workspaceName,
$change->originDimensionSpacePoint->toDimensionSpacePoint(),
$change->nodeAggregateId,
$workspaceName
$change->nodeAggregateId
);

/**
* See {@see Remove::apply} -> Removal Attachment Point == closest document node.
*/
$documentNodeAddress = new NodeAddress(
$change->contentStreamId,
$documentNodeAddress = NodeAddress::create(
$contentRepositoryId,
$workspaceName,
$change->originDimensionSpacePoint->toDimensionSpacePoint(),
$change->removalAttachmentPoint,
$workspaceName
$change->removalAttachmentPoint
);

$unpublishedNodes[] = [
'contextPath' => $nodeAddress->serializeForUri(),
'documentContextPath' => $documentNodeAddress->serializeForUri(),
'contextPath' => $nodeAddress->toJson(),
'documentContextPath' => $documentNodeAddress->toJson(),
'typeOfChange' => $this->getTypeOfChange($change)
];
} else {
Expand All @@ -89,11 +88,9 @@ public function getPublishableNodeInfo(WorkspaceName $workspaceName, ContentRepo
if ($node instanceof Node) {
$documentNode = $subgraph->findClosestNode($node->aggregateId, FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_DOCUMENT));
if ($documentNode instanceof Node) {
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);
$unpublishedNodes[] = [
'contextPath' => $nodeAddressFactory->createFromNode($node)->serializeForUri(),
'documentContextPath' => $nodeAddressFactory->createFromNode($documentNode)
->serializeForUri(),
'contextPath' => NodeAddress::fromNode($node)->toJson(),
'documentContextPath' => NodeAddress::fromNode($documentNode)->toJson(),
'typeOfChange' => $this->getTypeOfChange($change)
];
}
Expand Down
5 changes: 2 additions & 3 deletions Classes/Controller/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use Neos\Neos\Domain\Repository\SiteRepository;
use Neos\Neos\Domain\Service\NodeTypeNameFactory;
use Neos\Neos\Domain\Service\WorkspaceService;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\Neos\FrontendRouting\NodeUriBuilderFactory;
use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult;
use Neos\Neos\Service\UserService;
Expand Down Expand Up @@ -136,7 +135,7 @@ public function indexAction(string $node = null)
$siteDetectionResult = SiteDetectionResult::fromRequest($this->request->getHttpRequest());
$contentRepository = $this->contentRepositoryRegistry->get($siteDetectionResult->contentRepositoryId);

$nodeAddress = $node !== null ? NodeAddressFactory::create($contentRepository)->createFromUriString($node) : null;
$nodeAddress = $node !== null ? NodeAddress::fromJsonString($node) : null;
$user = $this->userService->getBackendUser();

if ($user === null) {
Expand Down Expand Up @@ -180,7 +179,7 @@ public function indexAction(string $node = null)
if (!$nodeAddress) {
$node = $siteNode;
} else {
$node = $subgraph->findNodeById($nodeAddress->nodeAggregateId);
$node = $subgraph->findNodeById($nodeAddress->aggregateId);
}

$this->view->setOption('title', 'Neos CMS');
Expand Down
Loading
Loading