Skip to content

Commit

Permalink
TASK: MenuHelper uses NodeDataRepository::findByPathWithoutReduce ins…
Browse files Browse the repository at this point in the history
…tead of ContentDimensionCombinator
  • Loading branch information
gjwnc committed Feb 6, 2024
1 parent 73e2eb3 commit 8fae658
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions Neos.Neos/Classes/Controller/Backend/MenuHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
* source code.
*/

use Neos\ContentRepository\Domain\Service\ContentDimensionCombinator;
use Neos\ContentRepository\Domain\Factory\NodeFactory;
use Neos\ContentRepository\Domain\Repository\NodeDataRepository;
use Neos\ContentRepository\Domain\Repository\WorkspaceRepository;
use Neos\ContentRepository\Domain\Utility\NodePaths;
use Neos\ContentRepository\Security\Authorization\Privilege\Node\NodePrivilegeSubject;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Http\Exception;
use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Flow\Mvc\Routing\Exception\MissingActionNameException;
use Neos\Flow\Security\Authorization\PrivilegeManagerInterface;
use Neos\Neos\Domain\Service\ContentContextFactory;
use Neos\Neos\Domain\Service\SiteService;
use Neos\Neos\Security\Authorization\Privilege\ModulePrivilege;
use Neos\Neos\Security\Authorization\Privilege\ModulePrivilegeSubject;
Expand Down Expand Up @@ -66,15 +68,21 @@ class MenuHelper

/**
* @Flow\Inject
* @var ContentContextFactory
* @var WorkspaceRepository
*/
protected $contextFactory;
protected $workspaceRepository;

/**
* @Flow\Inject
* @var ContentDimensionCombinator
* @var NodeDataRepository
*/
protected $contentDimensionCombinator;
protected $nodeDataRepository;

/**
* @Flow\Inject
* @var NodeFactory
*/
protected $nodeFactory;

/**
* @param array $settings
Expand All @@ -100,30 +108,22 @@ public function buildSiteList(ControllerContext $controllerContext): array
return [];
}

// generate ContentContext for all possible dimension combinations
$combinations = $this->contentDimensionCombinator->getAllAllowedCombinations();
$contentContexts = [];
foreach ($combinations as $dimensionCombination) {
$contentContexts[] = $this->contextFactory->create([
'dimensions' => $dimensionCombination,
'invisibleContentShown' => true,
'inaccessibleContentShown' => true,
]);
}
$liveWorkspace = $this->workspaceRepository->findByIdentifier('live');

$domainsFound = false;
$sites = [];
foreach ($this->siteRepository->findOnline() as $site) {
$granted = false;
foreach ($contentContexts as $context) {
// check if the site node exists in the context dimension
$node = $context->getNode(\Neos\ContentRepository\Domain\Utility\NodePaths::addNodePathSegment(SiteService::SITES_ROOT_PATH, $site->getNodeName()));
if (!$node) {
continue;
}

$siteNodePath = NodePaths::addNodePathSegment(SiteService::SITES_ROOT_PATH, $site->getNodeName());
$siteNodesInAllDimensions = $this->nodeDataRepository->findByPathWithoutReduce($siteNodePath, $liveWorkspace);

foreach ($siteNodesInAllDimensions as $siteNodeData) {
$siteNodeContext = $this->nodeFactory->createContextMatchingNodeData($siteNodeData);
$siteNode = $this->nodeFactory->createFromNodeData($siteNodeData, $siteNodeContext);

// if the node exists, check if the user is granted access to this node
if ($this->privilegeManager->isGranted(NodeTreePrivilege::class, new NodePrivilegeSubject($node))) {
if ($this->privilegeManager->isGranted(NodeTreePrivilege::class, new NodePrivilegeSubject($siteNode))) {
$granted = true;
break;
}
Expand Down

0 comments on commit 8fae658

Please sign in to comment.