Skip to content

Commit

Permalink
TASK: Replace ContentSubgraphIdentity in subgraph
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed May 13, 2024
1 parent 639ec76 commit 5c1e131
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ public function __construct(
$this->nodeQueryBuilder = new NodeQueryBuilder($this->client->getConnection(), $this->tableNames);
}

public function getContentRepositoryId(): ContentRepositoryId
{
return $this->contentRepositoryId;
}

public function getWorkspaceName(): WorkspaceName
{
return $this->workspaceName;
}

public function getSubgraph(
DimensionSpacePoint $dimensionSpacePoint,
VisibilityConstraints $visibilityConstraints
Expand Down Expand Up @@ -352,13 +362,6 @@ private function fetchRows(QueryBuilder $queryBuilder): array
}
}

/** The workspace this content graph is operating on */
public function getWorkspaceName(): WorkspaceName
{
return $this->workspaceName;
}

/** @internal The content stream id where the workspace name points to for this instance */
public function getContentStreamId(): ContentStreamId
{
return $this->contentStreamId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,24 @@ public function __construct(
$this->nodeQueryBuilder = new NodeQueryBuilder($this->client->getConnection(), $tableNames);
}

public function getIdentity(): ContentSubgraphIdentity
public function getContentRepositoryId(): ContentRepositoryId
{
return ContentSubgraphIdentity::create(
$this->contentRepositoryId,
$this->contentStreamId,
$this->dimensionSpacePoint,
$this->visibilityConstraints
);
return $this->contentRepositoryId;
}

public function getWorkspaceName(): WorkspaceName
{
return $this->workspaceName;
}

public function getDimensionSpacePoint(): DimensionSpacePoint
{
return $this->dimensionSpacePoint;
}

public function getVisibilityConstraints(): VisibilityConstraints
{
return $this->visibilityConstraints;
}

public function findChildNodes(NodeAggregateId $parentNodeAggregateId, FindChildNodesFilter $filter): Nodes
Expand Down Expand Up @@ -429,9 +439,15 @@ public function countNodes(): int
return $result;
}

public function jsonSerialize(): ContentSubgraphIdentity
/**
* @return array<string,mixed>
*/
public function jsonSerialize(): array
{
return $this->getIdentity();
return [
'workspaceName' => $this->workspaceName,
'dimensionSpacePoint' => $this->dimensionSpacePoint,
];
}

/** ------------------------------------------- */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ public function __construct(
$this->nodeFactory = $nodeFactory;
}

public function getContentRepositoryId(): ContentRepositoryId
{
return $this->contentRepositoryId;
}

public function getWorkspaceName(): WorkspaceName
{
return $this->workspaceName;
}

public function getSubgraph(
DimensionSpacePoint $dimensionSpacePoint,
VisibilityConstraints $visibilityConstraints
Expand All @@ -77,6 +87,7 @@ public function getSubgraph(
$this->subhypergraphs[$index] = new ContentSubhypergraph(
$this->contentRepositoryId,
$this->contentStreamId,
$this->workspaceName,
$dimensionSpacePoint,
$visibilityConstraints,
$this->databaseClient,
Expand Down Expand Up @@ -310,11 +321,6 @@ private function getDatabaseConnection(): DatabaseConnection
return $this->databaseClient->getConnection();
}

public function getWorkspaceName(): WorkspaceName
{
return $this->workspaceName;
}

public function getContentStreamId(): ContentStreamId
{
return $this->contentStreamId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
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;

/**
* The content subgraph application repository
Expand All @@ -76,6 +77,7 @@
public function __construct(
private ContentRepositoryId $contentRepositoryId,
private ContentStreamId $contentStreamId,
private WorkspaceName $workspaceName,
private DimensionSpacePoint $dimensionSpacePoint,
private VisibilityConstraints $visibilityConstraints,
private PostgresDbalClientInterface $databaseClient,
Expand All @@ -85,14 +87,24 @@ public function __construct(
) {
}

public function getIdentity(): ContentSubgraphIdentity
public function getContentRepositoryId(): ContentRepositoryId
{
return ContentSubgraphIdentity::create(
$this->contentRepositoryId,
$this->contentStreamId,
$this->dimensionSpacePoint,
$this->visibilityConstraints
);
return $this->contentRepositoryId;
}

public function getWorkspaceName(): WorkspaceName
{
return $this->workspaceName;
}

public function getDimensionSpacePoint(): DimensionSpacePoint
{
return $this->dimensionSpacePoint;
}

public function getVisibilityConstraints(): VisibilityConstraints
{
return $this->visibilityConstraints;
}

public function findNodeById(NodeAggregateId $nodeAggregateId): ?Node
Expand Down Expand Up @@ -534,8 +546,14 @@ private function getDatabaseConnection(): DatabaseConnection
return $this->databaseClient->getConnection();
}

public function jsonSerialize(): ContentSubgraphIdentity
/**
* @return array<string,mixed>
*/
public function jsonSerialize(): array
{
return $this->getIdentity();
return [
'workspaceName' => $this->workspaceName,
'dimensionSpacePoint' => $this->dimensionSpacePoint,
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\Projection\ProjectionStateInterface;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeAggregatesTypeIsAmbiguous;
use Neos\ContentRepository\Core\SharedModel\Exception\RootNodeAggregateDoesNotExist;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
Expand All @@ -37,6 +38,17 @@
*/
interface ContentGraphInterface extends ProjectionStateInterface
{
/**
* @api
*/
public function getContentRepositoryId(): ContentRepositoryId;

/**
* The workspace this content graph is operating on
* @api
*/
public function getWorkspaceName(): WorkspaceName;

/**
* @api main API method of ContentGraph
*/
Expand Down Expand Up @@ -151,9 +163,6 @@ public function getDimensionSpacePointsOccupiedByChildNodeName(
*/
public function countNodes(): int;

/** The workspace this content graph is operating on */
public function getWorkspaceName(): WorkspaceName;

/** @internal The content stream id where the workspace name points to for this instance */
public function getContentStreamId(): ContentStreamId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

namespace Neos\ContentRepository\Core\Projection\ContentGraph\ContentGraphWithRuntimeCaches;

use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\Projection\ContentGraph\AbsoluteNodePath;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphIdentity;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\CountBackReferencesFilter;
Expand All @@ -34,8 +34,11 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\Nodes;
use Neos\ContentRepository\Core\Projection\ContentGraph\References;
use Neos\ContentRepository\Core\Projection\ContentGraph\Subtree;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeName;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;

/**
* Wrapper for a concrete implementation of the {@see ContentSubgraphInterface} that
Expand All @@ -53,9 +56,24 @@ public function __construct(
$this->inMemoryCache = new InMemoryCache();
}

public function getIdentity(): ContentSubgraphIdentity
public function getContentRepositoryId(): ContentRepositoryId
{
return $this->wrappedContentSubgraph->getIdentity();
return $this->wrappedContentSubgraph->getContentRepositoryId();
}

public function getWorkspaceName(): WorkspaceName
{
return $this->wrappedContentSubgraph->getWorkspaceName();
}

public function getDimensionSpacePoint(): DimensionSpacePoint
{
return $this->wrappedContentSubgraph->getDimensionSpacePoint();
}

public function getVisibilityConstraints(): VisibilityConstraints
{
return $this->wrappedContentSubgraph->getVisibilityConstraints();
}

public function findChildNodes(NodeAggregateId $parentNodeAggregateId, FindChildNodesFilter $filter): Nodes
Expand Down Expand Up @@ -247,7 +265,10 @@ private static function isFilterEmpty(object $filter): bool
return array_filter(get_object_vars($filter), static fn ($value) => $value !== null) === [];
}

public function jsonSerialize(): ContentSubgraphIdentity
/**
* @return array<string,mixed>
*/
public function jsonSerialize(): array
{
return $this->wrappedContentSubgraph->jsonSerialize();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentRepository\Core\Feature\RootNodeCreation\RootNodeHandling;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
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;

/**
* This is the most important read model of a content repository.
Expand All @@ -46,16 +47,15 @@
*
* @api
*/
interface ContentSubgraphInterface extends \JsonSerializable
interface ContentSubgraphInterface
{
/**
* Returns the subgraph's identity, i.e. the current perspective we look at content from, composed of
* * the content repository the subgraph belongs to
* * the ID of the content stream we are currently working in
* * the dimension space point we are currently looking at
* * the applied visibility constraints
*/
public function getIdentity(): ContentSubgraphIdentity;
public function getContentRepositoryId(): ContentRepositoryId;

public function getWorkspaceName(): WorkspaceName;

public function getDimensionSpacePoint(): DimensionSpacePoint;

public function getVisibilityConstraints(): VisibilityConstraints;

/**
* Find a single node by its aggregate id
Expand Down Expand Up @@ -204,5 +204,9 @@ public function retrieveNodePath(NodeAggregateId $nodeAggregateId): AbsoluteNode
*/
public function countNodes(): int;

public function jsonSerialize(): ContentSubgraphIdentity;
/**
* @deprecated will be removed before Neos 9 release
* @return array<string,mixed>
*/
public function jsonSerialize(): array;
}
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ protected function getEntryPoints(array $contextNodes): array
foreach ($contextNodes as $contextNode) {
assert($contextNode instanceof Node);
$subgraph = $this->contentRepositoryRegistry->subgraphForNode($contextNode);
$subgraphIdentifier = md5($subgraph->getIdentity()->contentStreamId->value
. '@' . $contextNode->dimensionSpacePoint->toJson());
$subgraphIdentifier = md5($subgraph->getWorkspaceName()->value
. '@' . $subgraph->getDimensionSpacePoint()->toJson());
if (!isset($entryPoints[(string) $subgraphIdentifier])) {
$entryPoints[(string) $subgraphIdentifier] = [
'subgraph' => $subgraph,
Expand Down

0 comments on commit 5c1e131

Please sign in to comment.