Skip to content

Commit

Permalink
Merge pull request #4737 from mhsdesign/task/removeAndInlineInternalN…
Browse files Browse the repository at this point in the history
…odeSiteResolvingService

TASK: Inline `NodeSiteResolvingService`
  • Loading branch information
mhsdesign authored Nov 17, 2023
2 parents 1bc116a + ed68da8 commit 33a3c4b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 99 deletions.
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
elseif ($node === '~') {
$nodeAddress = $this->nodeAddressFactory->createFromNode($node);
$nodeAddress = $nodeAddress->withNodeAggregateId(
$this->nodeSiteResolvingService->findSiteNodeForNodeAddress($nodeAddress)->getNodeAggregateId()
$siteNode->nodeAggregateId
);
} 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

0 comments on commit 33a3c4b

Please sign in to comment.