Skip to content

Commit

Permalink
FEATURE: ContentGraphAdapter for write side access
Browse files Browse the repository at this point in the history
The write side no longer uses any regular finders
for checks but only accesses projection data via
the new `ContentGraphAdapterInterface`.

Fixes: neos#4973
  • Loading branch information
kitsunet committed Apr 5, 2024
1 parent 5260883 commit 8e3fd57
Show file tree
Hide file tree
Showing 29 changed files with 807 additions and 621 deletions.
@@ -0,0 +1,123 @@
<?php
namespace Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository;

use Doctrine\DBAL\Connection;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet;
use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint;
use Neos\ContentRepository\Core\Feature\ContentGraphAdapterInterface;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeName;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;

/**
*
*/
class ContentGraphAdapter implements ContentGraphAdapterInterface
{
public function __construct(
private readonly Connection $dbalConnection,
private readonly string $tableNamePrefix
)
{
}

public function rootNodeAggregateWithTypeExists(ContentStreamId $contentStreamId, NodeTypeName $nodeTypeName): bool
{
// TODO: Implement rootNodeAggregateWithTypeExists() method.
}

public function findParentNodeAggregates(ContentStreamId $contentStreamId, WorkspaceName $workspaceName, NodeAggregateId $childNodeAggregateId): iterable
{
// TODO: Implement findParentNodeAggregates() method.
}

public function findNodeAggregateById(ContentStreamId $contentStreamId, WorkspaceName $workspaceName, NodeAggregateId $nodeAggregateId): ?NodeAggregate
{
// TODO: Implement findNodeAggregateById() method.
}

public function findParentNodeAggregateByChildOriginDimensionSpacePoint(ContentStreamId $contentStreamId, WorkspaceName $workspaceName, NodeAggregateId $childNodeAggregateId, OriginDimensionSpacePoint $childOriginDimensionSpacePoint): ?NodeAggregate
{
// TODO: Implement findParentNodeAggregateByChildOriginDimensionSpacePoint() method.
}

public function findChildNodeAggregates(ContentStreamId $contentStreamId, WorkspaceName $workspaceName, NodeAggregateId $parentNodeAggregateId): iterable
{
// TODO: Implement findChildNodeAggregates() method.
}

public function findTetheredChildNodeAggregates(ContentStreamId $contentStreamId, WorkspaceName $workspaceName, NodeAggregateId $parentNodeAggregateId): iterable
{
// TODO: Implement findTetheredChildNodeAggregates() method.
}

public function getDimensionSpacePointsOccupiedByChildNodeName(ContentStreamId $contentStreamId, NodeName $nodeName, NodeAggregateId $parentNodeAggregateId, OriginDimensionSpacePoint $parentNodeOriginDimensionSpacePoint, DimensionSpacePointSet $dimensionSpacePointsToCheck): DimensionSpacePointSet
{
// TODO: Implement getDimensionSpacePointsOccupiedByChildNodeName() method.
}

public function findChildNodeAggregatesByName(ContentStreamId $contentStreamId, WorkspaceName $workspaceName, NodeAggregateId $parentNodeAggregateId, NodeName $name): iterable
{
// TODO: Implement findChildNodeAggregatesByName() method.
}

public function subgraphContainsNodes(ContentStreamId $contentStreamId, DimensionSpacePoint $dimensionSpacePoint): bool
{
// TODO: Implement subgraphContainsNodes() method.
}

public function findNodeInSubgraph(ContentStreamId $contentStreamId, WorkspaceName $workspaceName, DimensionSpacePoint $coveredDimensionSpacePoint, NodeAggregateId $nodeAggregateId): ?Node
{
// TODO: Implement findNodeInSubgraph() method.
}

public function findParentNodeInSubgraph(ContentStreamId $contentStreamId, WorkspaceName $workspaceName, DimensionSpacePoint $coveredDimensionSpacePoint, NodeAggregateId $childNodeAggregateId): ?Node
{
// TODO: Implement findParentNodeInSubgraph() method.
}

public function findChildNodeByNameInSubgraph(ContentStreamId $contentStreamId, WorkspaceName $workspaceName, DimensionSpacePoint $coveredDimensionSpacePoint, NodeAggregateId $parentNodeAggregateId, NodeName $nodeNamex): ?Node
{
// TODO: Implement findChildNodeByNameInSubgraph() method.
}

public function findPreceedingSiblingNodesInSubgraph(ContentStreamId $contentStreamId, WorkspaceName $workspaceName, DimensionSpacePoint $coveredDimensionSpacePoint, NodeAggregateId $startingSiblingNodeAggregateId): Nodes
{
// TODO: Implement findPreceedingSiblingNodesInSubgraph() method.
}

public function findSuceedingSiblingNodesInSubgraph(ContentStreamId $contentStreamId, WorkspaceName $workspaceName, DimensionSpacePoint $coveredDimensionSpacePoint, NodeAggregateId $startingSiblingNodeAggregateId): Nodes
{
// TODO: Implement findSuceedingSiblingNodesInSubgraph() method.
}

public function hasContentStream(ContentStreamId $contentStreamId): bool
{
// TODO: Implement hasContentStream() method.
}

public function findStateForContentStream(ContentStreamId $contentStreamId): ?ContentStreamState
{
// TODO: Implement findStateForContentStream() method.
}

public function findVersionForContentStream(ContentStreamId $contentStreamId): MaybeVersion
{
// TODO: Implement findVersionForContentStream() method.
}

public function findWorkspaceByName(WorkspaceName $workspaceName): ?Workspace
{
// TODO: Implement findWorkspaceByName() method.
}

public function findWorkspaceByCurrentContentStreamId(ContentStreamId $contentStreamId): ?Workspace
{
// TODO: Implement findWorkspaceByCurrentContentStreamId() method.
}
}
@@ -0,0 +1,27 @@
<?php
namespace Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository;

use Doctrine\DBAL\Connection;
use Neos\ContentGraph\DoctrineDbalAdapter\DoctrineDbalContentGraphProjectionFactory;
use Neos\ContentRepository\Core\Feature\ContentGraphAdapterFactoryInterface;
use Neos\ContentRepository\Core\Feature\ContentGraphAdapterInterface;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;

/**
* This factory
*/
class ContentGraphAdapterFactory implements ContentGraphAdapterFactoryInterface
{
public function __construct(
readonly Connection $dbalConnection
) {
}

public function build(ContentRepositoryId $contentRepositoryId): ContentGraphAdapterInterface
{
$tableNamePrefix = DoctrineDbalContentGraphProjectionFactory::graphProjectionTableNamePrefix(
$contentRepositoryId
);
return new ContentGraphAdapter($this->dbalConnection, $tableNamePrefix);
}
}
9 changes: 9 additions & 0 deletions Neos.ContentRepository.Core/Classes/ContentRepository.php
Expand Up @@ -29,6 +29,7 @@
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\Projection\CatchUp;
use Neos\ContentRepository\Core\Projection\CatchUpOptions;
use Neos\ContentRepository\Core\Feature\ContentGraphAdapterInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphInterface;
use Neos\ContentRepository\Core\Projection\ContentStream\ContentStreamFinder;
use Neos\ContentRepository\Core\Projection\ProjectionInterface;
Expand Down Expand Up @@ -258,4 +259,12 @@ public function getContentDimensionSource(): ContentDimensionSourceInterface
{
return $this->contentDimensionSource;
}

/**
* @internal
*/
public function getContentGraphAdapter(): ContentGraphAdapterInterface
{
return $this->getContentGraph();
}
}
Expand Up @@ -21,6 +21,7 @@
use Neos\ContentRepository\Core\DimensionSpace\InterDimensionalVariationGraph;
use Neos\ContentRepository\Core\EventStore\EventNormalizer;
use Neos\ContentRepository\Core\EventStore\EventPersister;
use Neos\ContentRepository\Core\Feature\ContentGraphAdapterFactoryInterface;
use Neos\ContentRepository\Core\Feature\ContentStreamCommandHandler;
use Neos\ContentRepository\Core\Feature\DimensionSpaceAdjustment\DimensionSpaceCommandHandler;
use Neos\ContentRepository\Core\Feature\NodeAggregateCommandHandler;
Expand Down Expand Up @@ -56,6 +57,7 @@ public function __construct(
private readonly ProjectionCatchUpTriggerInterface $projectionCatchUpTrigger,
private readonly UserIdProviderInterface $userIdProvider,
private readonly ClockInterface $clock,
private readonly ContentGraphAdapterFactoryInterface $contentGraphAdapterFactory,
) {
$contentDimensionZookeeper = new ContentDimensionZookeeper($contentDimensionSource);
$interDimensionalVariationGraph = new InterDimensionalVariationGraph(
Expand Down Expand Up @@ -132,19 +134,23 @@ public function buildService(
private function buildCommandBus(): CommandBus
{
if (!$this->commandBus) {
$contentGraphAdapter = $this->contentGraphAdapterFactory->build($this->projectionFactoryDependencies->contentRepositoryId);
$this->commandBus = new CommandBus(
new ContentStreamCommandHandler(
$contentGraphAdapter
),
new WorkspaceCommandHandler(
$this->buildEventPersister(),
$this->projectionFactoryDependencies->eventStore,
$this->projectionFactoryDependencies->eventNormalizer,
$contentGraphAdapter
),
new NodeAggregateCommandHandler(
$this->projectionFactoryDependencies->nodeTypeManager,
$this->projectionFactoryDependencies->contentDimensionZookeeper,
$this->projectionFactoryDependencies->interDimensionalVariationGraph,
$this->projectionFactoryDependencies->propertyConverter
$this->projectionFactoryDependencies->propertyConverter,
$contentGraphAdapter
),
new DimensionSpaceCommandHandler(
$this->projectionFactoryDependencies->contentDimensionZookeeper,
Expand Down

0 comments on commit 8e3fd57

Please sign in to comment.