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: Inline NodeSiteResolvingService #4737

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
18 changes: 3 additions & 15 deletions Neos.Neos/Classes/Controller/Frontend/NodeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
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\FindClosestNodeFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindSubtreeFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ContentGraph\Nodes;
Expand All @@ -34,7 +35,6 @@
use Neos\Flow\Session\SessionInterface;
use Neos\Flow\Utility\Now;
use Neos\Neos\Domain\Model\RenderingMode;
use Neos\Neos\Domain\Service\NodeSiteResolvingService;
use Neos\Neos\Domain\Service\NodeTypeNameFactory;
use Neos\Neos\Domain\Service\RenderingModeService;
use Neos\Neos\FrontendRouting\Exception\InvalidShortcutException;
Expand Down Expand Up @@ -103,12 +103,6 @@ class NodeController extends ActionController
*/
protected $view;

/**
* @Flow\Inject
* @var NodeSiteResolvingService
*/
protected $nodeSiteResolvingService;

#[Flow\Inject]
protected RenderingModeService $renderingModeService;

Expand Down Expand Up @@ -145,10 +139,7 @@ public function previewAction(string $node): void
$visibilityConstraints
);

$site = $this->nodeSiteResolvingService->findSiteNodeForNodeAddress(
$nodeAddress,
$siteDetectionResult->contentRepositoryId
);
$site = $subgraph->findClosestNode($nodeAddress->nodeAggregateId, FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_SITE));
if ($site === null) {
throw new NodeNotFoundException("TODO: SITE NOT FOUND; should not happen (for address " . $nodeAddress);
}
Expand Down Expand Up @@ -214,10 +205,7 @@ public function showAction(string $node): void
VisibilityConstraints::frontend()
);

$site = $this->nodeSiteResolvingService->findSiteNodeForNodeAddress(
$nodeAddress,
$siteDetectionResult->contentRepositoryId
);
$site = $subgraph->findClosestNode($nodeAddress->nodeAggregateId, FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_SITE));
if ($site === null) {
throw new NodeNotFoundException("TODO: SITE NOT FOUND; should not happen (for address " . $nodeAddress);
}
Expand Down
55 changes: 0 additions & 55 deletions Neos.Neos/Classes/Domain/Service/NodeSiteResolvingService.php

This file was deleted.

4 changes: 2 additions & 2 deletions Neos.Neos/Classes/Fusion/NodeUriImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ public function evaluate()
} else {
return '';
}
/** @todo implement us
/* TODO implement us see https://github.com/neos/neos-development-collection/issues/4524 {@see \Neos\Neos\ViewHelpers\Uri\NodeViewHelper::resolveNodeAddressFromString} for an example implementation
mhsdesign marked this conversation as resolved.
Show resolved Hide resolved
elseif ($node === '~') {
$nodeAddress = $this->nodeAddressFactory->createFromNode($node);
$nodeAddress = $nodeAddress->withNodeAggregateId(
$this->nodeSiteResolvingService->findSiteNodeForNodeAddress($nodeAddress)->getNodeAggregateId()
$siteNode->nodeAggregateId
mhsdesign marked this conversation as resolved.
Show resolved Hide resolved
);
} elseif (is_string($node) && substr($node, 0, 7) === 'node://') {
$nodeAddress = $this->nodeAddressFactory->createFromNode($node);
Expand Down
15 changes: 2 additions & 13 deletions Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace Neos\Neos\ViewHelpers\Link;

use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindClosestNodeFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodePath;
Expand All @@ -32,7 +33,6 @@
use Neos\FluidAdaptor\Core\ViewHelper\AbstractTagBasedViewHelper;
use Neos\FluidAdaptor\Core\ViewHelper\Exception as ViewHelperException;
use Neos\Fusion\ViewHelpers\FusionContextTrait;
use Neos\Neos\Domain\Service\NodeSiteResolvingService;
use Neos\Neos\FrontendRouting\Exception\InvalidShortcutException;
use Neos\Neos\FrontendRouting\Exception\NodeNotFoundException;
use Neos\Neos\FrontendRouting\NodeShortcutResolver;
Expand Down Expand Up @@ -137,12 +137,6 @@ class NodeViewHelper extends AbstractTagBasedViewHelper
*/
protected $tagName = 'a';

/**
* @Flow\Inject
* @var NodeSiteResolvingService
*/
protected $nodeSiteResolvingService;

/**
* @Flow\Inject
* @var NodeShortcutResolver
Expand Down Expand Up @@ -382,12 +376,7 @@ private function resolveNodeAddressFromString(
VisibilityConstraints::withoutRestrictions()
);
if (strncmp($path, '~', 1) === 0) {
// TODO: This can be simplified
// once https://github.com/neos/contentrepository-development-collection/issues/164 is resolved
$siteNode = $this->nodeSiteResolvingService->findSiteNodeForNodeAddress(
$documentNodeAddress,
$documentNode->subgraphIdentity->contentRepositoryId
);
$siteNode = $subgraph->findClosestNode($documentNodeAddress->nodeAggregateId, FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_SITE));
if ($siteNode === null) {
throw new ViewHelperException(sprintf(
'Failed to determine site node for aggregate node "%s" and subgraph "%s"',
Expand Down
17 changes: 3 additions & 14 deletions Neos.Neos/Classes/ViewHelpers/Uri/NodeViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@

namespace Neos\Neos\ViewHelpers\Uri;

use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphIdentity;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindClosestNodeFilter;
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;
Expand All @@ -31,7 +32,6 @@
use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper;
use Neos\FluidAdaptor\Core\ViewHelper\Exception as ViewHelperException;
use Neos\Fusion\ViewHelpers\FusionContextTrait;
use Neos\Neos\Domain\Service\NodeSiteResolvingService;
use Neos\Neos\FrontendRouting\NodeUriBuilder;

/**
Expand Down Expand Up @@ -112,12 +112,6 @@ class NodeViewHelper extends AbstractViewHelper
*/
protected $contentRepositoryRegistry;

/**
* @Flow\Inject
* @var NodeSiteResolvingService
*/
protected $nodeSiteResolvingService;

/**
* @Flow\Inject
* @var ThrowableStorageInterface
Expand Down Expand Up @@ -285,12 +279,7 @@ private function resolveNodeAddressFromString(string $path): ?NodeAddress
VisibilityConstraints::withoutRestrictions()
);
if (strncmp($path, '~', 1) === 0) {
// TODO: This can be simplified
// once https://github.com/neos/contentrepository-development-collection/issues/164 is resolved
$siteNode = $this->nodeSiteResolvingService->findSiteNodeForNodeAddress(
$documentNodeAddress,
$documentNode->subgraphIdentity->contentRepositoryId
);
$siteNode = $subgraph->findClosestNode($documentNodeAddress->nodeAggregateId, FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_SITE));
if ($siteNode === null) {
throw new ViewHelperException(sprintf(
'Failed to determine site node for aggregate node "%s" and subgraph "%s"',
Expand Down
Loading