Skip to content

Commit

Permalink
WIP: VirtualWorkspaceName
Browse files Browse the repository at this point in the history
  • Loading branch information
kitsunet committed Oct 19, 2024
1 parent a84770f commit 4087999
Show file tree
Hide file tree
Showing 58 changed files with 345 additions and 198 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreams;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamStatus;
use Neos\ContentRepository\Core\SharedModel\Workspace\VirtualWorkspaceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\Workspace;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\Workspaces;
Expand All @@ -46,7 +47,7 @@ public function __construct(
) {
}

public function buildContentGraph(WorkspaceName $workspaceName, ContentStreamId $contentStreamId): ContentGraph
public function buildContentGraph(WorkspaceName|VirtualWorkspaceName $workspaceName, ContentStreamId $contentStreamId): ContentGraph
{
return new ContentGraph($this->dbal, $this->nodeFactory, $this->contentRepositoryId, $this->nodeTypeManager, $this->tableNames, $workspaceName, $contentStreamId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,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\VirtualWorkspaceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;

/**
Expand Down Expand Up @@ -70,7 +71,7 @@ public function __construct(
private readonly ContentRepositoryId $contentRepositoryId,
private readonly NodeTypeManager $nodeTypeManager,
private readonly ContentGraphTableNames $tableNames,
public readonly WorkspaceName $workspaceName,
public readonly WorkspaceName|VirtualWorkspaceName $workspaceName,
public readonly ContentStreamId $contentStreamId
) {
$this->nodeQueryBuilder = new NodeQueryBuilder($this->dbal, $this->tableNames);
Expand All @@ -81,7 +82,7 @@ public function getContentRepositoryId(): ContentRepositoryId
return $this->contentRepositoryId;
}

public function getWorkspaceName(): WorkspaceName
public function getWorkspaceName(): WorkspaceName|VirtualWorkspaceName
{
return $this->workspaceName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
use Neos\ContentRepository\Core\SharedModel\Node\NodeName;
use Neos\ContentRepository\Core\SharedModel\Node\PropertyName;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\VirtualWorkspaceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;

/**
Expand Down Expand Up @@ -90,7 +91,7 @@ final class ContentSubgraph implements ContentSubgraphInterface

public function __construct(
private readonly ContentRepositoryId $contentRepositoryId,
private readonly WorkspaceName $workspaceName,
private readonly WorkspaceName|VirtualWorkspaceName $workspaceName,
private readonly ContentStreamId $contentStreamId,
private readonly DimensionSpacePoint $dimensionSpacePoint,
private readonly VisibilityConstraints $visibilityConstraints,
Expand All @@ -107,7 +108,7 @@ public function getContentRepositoryId(): ContentRepositoryId
return $this->contentRepositoryId;
}

public function getWorkspaceName(): WorkspaceName
public function getWorkspaceName(): WorkspaceName|VirtualWorkspaceName
{
return $this->workspaceName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
use Neos\ContentRepository\Core\SharedModel\Node\NodeName;
use Neos\ContentRepository\Core\SharedModel\Node\ReferenceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\VirtualWorkspaceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Traversable;

Expand All @@ -63,7 +64,7 @@ public function __construct(
*/
public function mapNodeRowToNode(
array $nodeRow,
WorkspaceName $workspaceName,
WorkspaceName|VirtualWorkspaceName $workspaceName,
DimensionSpacePoint $dimensionSpacePoint,
VisibilityConstraints $visibilityConstraints
): Node {
Expand Down Expand Up @@ -93,7 +94,7 @@ public function mapNodeRowToNode(
*/
public function mapNodeRowsToNodes(
array $nodeRows,
WorkspaceName $workspaceName,
WorkspaceName|VirtualWorkspaceName $workspaceName,
DimensionSpacePoint $dimensionSpacePoint,
VisibilityConstraints $visibilityConstraints
): Nodes {
Expand All @@ -120,7 +121,7 @@ public function createPropertyCollectionFromJsonString(string $jsonString): Prop
*/
public function mapReferenceRowsToReferences(
array $nodeRows,
WorkspaceName $workspaceName,
WorkspaceName|VirtualWorkspaceName $workspaceName,
DimensionSpacePoint $dimensionSpacePoint,
VisibilityConstraints $visibilityConstraints
): References {
Expand Down Expand Up @@ -150,7 +151,7 @@ public function mapReferenceRowsToReferences(
*/
public function mapNodeRowsToNodeAggregate(
array $nodeRows,
WorkspaceName $workspaceName,
WorkspaceName|VirtualWorkspaceName $workspaceName,
VisibilityConstraints $visibilityConstraints
): ?NodeAggregate {
if (empty($nodeRows)) {
Expand Down Expand Up @@ -231,7 +232,7 @@ public function mapNodeRowsToNodeAggregate(
*/
public function mapNodeRowsToNodeAggregates(
array $nodeRows,
WorkspaceName $workspaceName,
WorkspaceName|VirtualWorkspaceName $workspaceName,
VisibilityConstraints $visibilityConstraints
): NodeAggregates {
if (empty($nodeRows)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStream;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreams;
use Neos\ContentRepository\Core\SharedModel\Workspace\VirtualWorkspaceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\Workspace;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\Workspaces;
Expand All @@ -34,7 +35,7 @@ public function __construct(
) {
}

public function buildContentGraph(WorkspaceName $workspaceName, ContentStreamId $contentStreamId): ContentGraphInterface
public function buildContentGraph(WorkspaceName|VirtualWorkspaceName $workspaceName, ContentStreamId $contentStreamId): ContentGraphInterface
{
return new ContentHyperGraph($this->dbal, $this->nodeFactory, $this->contentRepositoryId, $this->nodeTypeManager, $this->tableNamePrefix, $workspaceName, $contentStreamId);

Check failure on line 40 in Neos.ContentGraph.PostgreSQLAdapter/src/ContentHyperRepositoryReadModelAdapter.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 Test linting-unit-functionaltests-mysql (deps: highest)

Parameter #6 $workspaceName of class Neos\ContentGraph\PostgreSQLAdapter\Domain\Repository\ContentHypergraph constructor expects Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName, Neos\ContentRepository\Core\SharedModel\Workspace\VirtualWorkspaceName|Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName given.

Check failure on line 40 in Neos.ContentGraph.PostgreSQLAdapter/src/ContentHyperRepositoryReadModelAdapter.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 Test linting-unit-functionaltests-mysql (deps: highest)

Parameter #6 $workspaceName of class Neos\ContentGraph\PostgreSQLAdapter\Domain\Repository\ContentHypergraph constructor expects Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName, Neos\ContentRepository\Core\SharedModel\Workspace\VirtualWorkspaceName|Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName given.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Neos\ContentRepository\Core\SharedModel\Exception\WorkspaceDoesNotExist;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamStatus;
use Neos\ContentRepository\Core\SharedModel\Workspace\VirtualWorkspaceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\EventStore\Model\Event\Version;

Expand Down Expand Up @@ -78,8 +79,12 @@ public function findWorkspaceByName(WorkspaceName $workspaceName): ?Workspace
/**
* @throws WorkspaceDoesNotExist if the workspace does not exist
*/
public function getContentGraph(WorkspaceName $workspaceName): ContentGraphInterface
public function getContentGraph(WorkspaceName|VirtualWorkspaceName $workspaceName): ContentGraphInterface
{
if ($workspaceName instanceof VirtualWorkspaceName) {
return $this->contentRepository->projectionState(ContentRepositoryReadModel::class)->getContentGraphByWorkspaceNameAndContentStreamId($workspaceName, $workspaceName->contentStreamId);
}

if (isset($this->overriddenContentGraphInstances[$workspaceName->value])) {
return $this->overriddenContentGraphInstances[$workspaceName->value];
}
Expand Down
6 changes: 5 additions & 1 deletion Neos.ContentRepository.Core/Classes/ContentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
use Neos\ContentRepository\Core\SharedModel\Exception\WorkspaceDoesNotExist;
use Neos\ContentRepository\Core\SharedModel\User\UserIdProviderInterface;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStream;
use Neos\ContentRepository\Core\SharedModel\Workspace\VirtualWorkspaceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreams;
use Neos\ContentRepository\Core\SharedModel\Workspace\Workspace;
Expand Down Expand Up @@ -240,8 +241,11 @@ public function resetProjectionState(string $projectionClassName): void
/**
* @throws WorkspaceDoesNotExist if the workspace does not exist
*/
public function getContentGraph(WorkspaceName $workspaceName): ContentGraphInterface
public function getContentGraph(WorkspaceName|VirtualWorkspaceName $workspaceName): ContentGraphInterface
{
if ($workspaceName instanceof VirtualWorkspaceName) {
return $this->getContentRepositoryReadModel()->getContentGraphByWorkspaceNameAndContentStreamId($workspaceName, $workspaceName->contentStreamId);
}
return $this->getContentRepositoryReadModel()->getContentGraphByWorkspaceName($workspaceName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStream;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreams;
use Neos\ContentRepository\Core\SharedModel\Workspace\VirtualWorkspaceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\Workspace;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\Workspaces;
Expand Down Expand Up @@ -66,7 +67,7 @@ public function findContentStreams(): ContentStreams
* @throws WorkspaceDoesNotExist if the provided workspace does not resolve to an existing content stream
* @see ContentRepository::getContentGraph()
*/
public function getContentGraphByWorkspaceName(WorkspaceName $workspaceName): ContentGraphInterface
public function getContentGraphByWorkspaceName(WorkspaceName|VirtualWorkspaceName $workspaceName): ContentGraphInterface
{
$workspace = $this->findWorkspaceByName($workspaceName);

Check failure on line 72 in Neos.ContentRepository.Core/Classes/ContentRepositoryReadModel.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 Test linting-unit-functionaltests-mysql (deps: highest)

Parameter #1 $workspaceName of method Neos\ContentRepository\Core\ContentRepositoryReadModel::findWorkspaceByName() expects Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName, Neos\ContentRepository\Core\SharedModel\Workspace\VirtualWorkspaceName|Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName given.

Check failure on line 72 in Neos.ContentRepository.Core/Classes/ContentRepositoryReadModel.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 Test linting-unit-functionaltests-mysql (deps: highest)

Parameter #1 $workspaceName of method Neos\ContentRepository\Core\ContentRepositoryReadModel::findWorkspaceByName() expects Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName, Neos\ContentRepository\Core\SharedModel\Workspace\VirtualWorkspaceName|Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName given.
if ($workspace === null) {
Expand All @@ -78,11 +79,11 @@ public function getContentGraphByWorkspaceName(WorkspaceName $workspaceName): Co
/**
* For testing we allow getting an instance set by both parameters, effectively overriding the relationship at will
*
* @param WorkspaceName $workspaceName
* @param WorkspaceName|VirtualWorkspaceName $workspaceName
* @param ContentStreamId $contentStreamId
* @internal Only for testing
*/
public function getContentGraphByWorkspaceNameAndContentStreamId(WorkspaceName $workspaceName, ContentStreamId $contentStreamId): ContentGraphInterface
public function getContentGraphByWorkspaceNameAndContentStreamId(WorkspaceName|VirtualWorkspaceName $workspaceName, ContentStreamId $contentStreamId): ContentGraphInterface
{
return $this->adapter->buildContentGraph($workspaceName, $contentStreamId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStream;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreams;
use Neos\ContentRepository\Core\SharedModel\Workspace\VirtualWorkspaceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\Workspace;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\Workspaces;
Expand All @@ -30,7 +31,7 @@
*/
interface ContentRepositoryReadModelAdapterInterface
{
public function buildContentGraph(WorkspaceName $workspaceName, ContentStreamId $contentStreamId): ContentGraphInterface;
public function buildContentGraph(WorkspaceName|VirtualWorkspaceName $workspaceName, ContentStreamId $contentStreamId): ContentGraphInterface;

public function findWorkspaceByName(WorkspaceName $workspaceName): ?Workspace;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
use Neos\ContentRepository\Core\SharedModel\Node\ReferenceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamStatus;
use Neos\ContentRepository\Core\SharedModel\Workspace\VirtualWorkspaceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\EventStore\Model\EventStream\ExpectedVersion;

Expand All @@ -77,9 +78,12 @@ abstract protected function getAllowedDimensionSubspace(): DimensionSpacePointSe
* @throws ContentStreamDoesNotExistYet
*/
protected function requireContentStream(
WorkspaceName $workspaceName,
WorkspaceName|VirtualWorkspaceName $workspaceName,
CommandHandlingDependencies $commandHandlingDependencies
): ContentStreamId {
if ($workspaceName instanceof VirtualWorkspaceName && $commandHandlingDependencies->contentStreamExists($workspaceName->contentStreamId)) {
return $workspaceName->contentStreamId;
}
$contentStreamId = $commandHandlingDependencies->getContentGraph($workspaceName)->getContentStreamId();
if (!$commandHandlingDependencies->contentStreamExists($contentStreamId)) {
throw new ContentStreamDoesNotExistYet(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace Neos\ContentRepository\Core\Feature\Common;

use Neos\ContentRepository\Core\SharedModel\Workspace\VirtualWorkspaceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;

/**
Expand All @@ -25,5 +26,5 @@
*/
interface EmbedsWorkspaceName
{
public function getWorkspaceName(): WorkspaceName;
public function getWorkspaceName(): WorkspaceName|VirtualWorkspaceName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace Neos\ContentRepository\Core\Feature\Common;

use Neos\ContentRepository\Core\CommandHandler\CommandInterface;
use Neos\ContentRepository\Core\SharedModel\Workspace\VirtualWorkspaceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;

/**
Expand All @@ -28,7 +29,7 @@
interface RebasableToOtherWorkspaceInterface
{
public function createCopyForWorkspace(
WorkspaceName $targetWorkspaceName,
WorkspaceName|VirtualWorkspaceName $targetWorkspaceName,
): CommandInterface;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentRepository\Core\Feature\Common\RebasableToOtherWorkspaceInterface;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\VirtualWorkspaceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;

/**
Expand All @@ -39,24 +40,24 @@
RebasableToOtherWorkspaceInterface
{
/**
* @param WorkspaceName $workspaceName The name of the workspace to perform the operation in.
* @param WorkspaceName|VirtualWorkspaceName $workspaceName The name of the workspace to perform the operation in.
* @param DimensionSpacePoint $source source dimension space point
* @param DimensionSpacePoint $target target dimension space point
*/
private function __construct(
public WorkspaceName $workspaceName,
public WorkspaceName|VirtualWorkspaceName $workspaceName,
public DimensionSpacePoint $source,
public DimensionSpacePoint $target
) {
}

/**
* @param WorkspaceName $workspaceName The name of the workspace to perform the operation in
* @param WorkspaceName|VirtualWorkspaceName $workspaceName The name of the workspace to perform the operation in
* @param DimensionSpacePoint $source source dimension space point
* @param DimensionSpacePoint $target target dimension space point
*/
public static function create(
WorkspaceName $workspaceName,
WorkspaceName|VirtualWorkspaceName $workspaceName,
DimensionSpacePoint $source,
DimensionSpacePoint $target
): self {
Expand All @@ -75,7 +76,7 @@ public static function fromArray(array $array): self
);
}

public function createCopyForWorkspace(WorkspaceName $targetWorkspaceName): self
public function createCopyForWorkspace(WorkspaceName|VirtualWorkspaceName $targetWorkspaceName): self
{
return new self(
$targetWorkspaceName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Neos\ContentRepository\Core\CommandHandler\CommandInterface;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentRepository\Core\Feature\Common\RebasableToOtherWorkspaceInterface;
use Neos\ContentRepository\Core\SharedModel\Workspace\VirtualWorkspaceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;

/**
Expand All @@ -34,24 +35,24 @@
RebasableToOtherWorkspaceInterface
{
/**
* @param WorkspaceName $workspaceName The name of the workspace to perform the operation in.
* @param WorkspaceName|VirtualWorkspaceName $workspaceName The name of the workspace to perform the operation in.
* @param DimensionSpacePoint $source source dimension space point
* @param DimensionSpacePoint $target target dimension space point
*/
private function __construct(
public WorkspaceName $workspaceName,
public WorkspaceName|VirtualWorkspaceName $workspaceName,
public DimensionSpacePoint $source,
public DimensionSpacePoint $target,
) {
}

/**
* @param WorkspaceName $workspaceName The name of the workspace to perform the operation in
* @param WorkspaceName|VirtualWorkspaceName $workspaceName The name of the workspace to perform the operation in
* @param DimensionSpacePoint $source source dimension space point
* @param DimensionSpacePoint $target target dimension space point
*/
public static function create(
WorkspaceName $workspaceName,
WorkspaceName|VirtualWorkspaceName $workspaceName,
DimensionSpacePoint $source,
DimensionSpacePoint $target
): self {
Expand All @@ -71,7 +72,7 @@ public static function fromArray(array $array): self
}

public function createCopyForWorkspace(
WorkspaceName $targetWorkspaceName,
WorkspaceName|VirtualWorkspaceName $targetWorkspaceName,
): self {
return new self(
$targetWorkspaceName,
Expand Down
Loading

0 comments on commit 4087999

Please sign in to comment.