Skip to content

Commit

Permalink
WIP: Feature: Add ContentRepository::getSubgraph
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Feb 20, 2024
1 parent b1faa80 commit ae02b4c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 18 deletions.
24 changes: 24 additions & 0 deletions Neos.ContentRepository.Core/Classes/ContentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,18 @@
use Neos\ContentRepository\Core\Projection\CatchUp;
use Neos\ContentRepository\Core\Projection\CatchUpOptions;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\Projection\ContentStream\ContentStreamFinder;
use Neos\ContentRepository\Core\Projection\ProjectionInterface;
use Neos\ContentRepository\Core\Projection\ProjectionsAndCatchUpHooks;
use Neos\ContentRepository\Core\Projection\ProjectionStateInterface;
use Neos\ContentRepository\Core\Projection\ProjectionStatuses;
use Neos\ContentRepository\Core\Projection\Workspace\WorkspaceFinder;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryStatus;
use Neos\ContentRepository\Core\SharedModel\Node\NodeIdentity;
use Neos\ContentRepository\Core\SharedModel\User\UserIdProviderInterface;
use Neos\ContentRepository\Core\SharedModel\Workspace\DetachedWorkspaceName;
use Neos\EventStore\EventStoreInterface;
use Neos\EventStore\Model\Event\EventMetadata;
use Neos\EventStore\Model\EventEnvelope;
Expand Down Expand Up @@ -229,6 +233,26 @@ public function resetProjectionState(string $projectionClassName): void
$projection->reset();
}

public function getSubgraph(NodeIdentity $nodeIdentity, VisibilityConstraints $visibilityConstraints): ContentSubgraphInterface
{
if ($nodeIdentity->workspaceName instanceof DetachedWorkspaceName) {
return $this->getContentGraph()->getSubgraph(
$nodeIdentity->workspaceName->contentStreamId,
$nodeIdentity->dimensionSpacePoint,
$visibilityConstraints
);
}
$workspace = $this->getWorkspaceFinder()->findOneByName($nodeIdentity->workspaceName);
if (!$workspace) {
throw new \RuntimeException(sprintf('Workspace could not be found while for NodeIdentity<%s>.', json_encode($nodeIdentity, JSON_PARTIAL_OUTPUT_ON_ERROR)), 1708431634);
}
return $this->getContentGraph()->getSubgraph(
$workspace,
$nodeIdentity->dimensionSpacePoint,
$visibilityConstraints
);
}

public function getNodeTypeManager(): NodeTypeManager
{
return $this->nodeTypeManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ public function resetFactoryInstance(ContentRepositoryId $contentRepositoryId):
public function subgraphForNode(Node $node): ContentSubgraphInterface
{
$contentRepository = $this->get($node->subgraphIdentity->contentRepositoryId);
return $contentRepository->getContentGraph()->getSubgraph(
$node->subgraphIdentity->contentStreamId,
$node->subgraphIdentity->dimensionSpacePoint,
return $contentRepository->getSubgraph(
$node->identity,
$node->subgraphIdentity->visibilityConstraints
);
}
Expand Down
30 changes: 15 additions & 15 deletions Neos.Neos/Configuration/Settings.ContentRepositoryRegistry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ Neos:
userIdProvider:
factoryObjectName: Neos\Neos\UserIdProvider\UserIdProviderFactory

projections:
'Neos.Neos:DocumentUriPathProjection':
factoryObjectName: Neos\Neos\FrontendRouting\Projection\DocumentUriPathProjectionFactory
catchUpHooks:
'Neos.Neos:FlushRouteCache':
factoryObjectName: Neos\Neos\FrontendRouting\CatchUpHook\RouterCacheHookFactory

'Neos.Neos:PendingChangesProjection':
factoryObjectName: Neos\Neos\PendingChangesProjection\ChangeProjectionFactory
'Neos.ContentRepository:ContentGraph':
catchUpHooks:
'Neos.Neos:FlushContentCache':
factoryObjectName: Neos\Neos\Fusion\Cache\GraphProjectorCatchUpHookForCacheFlushingFactory
'Neos.Neos:AssetUsage':
factoryObjectName: Neos\Neos\AssetUsage\Projection\AssetUsageProjectionFactory
# projections:
# 'Neos.Neos:DocumentUriPathProjection':
# factoryObjectName: Neos\Neos\FrontendRouting\Projection\DocumentUriPathProjectionFactory
# catchUpHooks:
# 'Neos.Neos:FlushRouteCache':
# factoryObjectName: Neos\Neos\FrontendRouting\CatchUpHook\RouterCacheHookFactory
#
# 'Neos.Neos:PendingChangesProjection':
# factoryObjectName: Neos\Neos\PendingChangesProjection\ChangeProjectionFactory
# 'Neos.ContentRepository:ContentGraph':
# catchUpHooks:
# 'Neos.Neos:FlushContentCache':
# factoryObjectName: Neos\Neos\Fusion\Cache\GraphProjectorCatchUpHookForCacheFlushingFactory
# 'Neos.Neos:AssetUsage':
# factoryObjectName: Neos\Neos\AssetUsage\Projection\AssetUsageProjectionFactory

0 comments on commit ae02b4c

Please sign in to comment.