Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

!!! FEATURE: Add workspaceName to relevant events #5002

Merged
merged 21 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6f3be98
WIP: FEATURE: Add `workspaceName` to relevant events
bwaidelich Apr 19, 2024
c3019e6
Merge branch '9.0' into feature/4996-add-workspacename-to-events
bwaidelich May 1, 2024
dfd1007
Merge branch '9.0' into feature/4996-add-workspacename-to-events
bwaidelich May 17, 2024
ce99c0b
Fix NodeVariationInternals
bwaidelich May 17, 2024
85d2922
Remove unused `getWorkspaceName()` from `EmbedsContentStreamAndNodeAg…
bwaidelich May 17, 2024
f4d2f41
Rename and tweak `PublishableInterface`
bwaidelich May 17, 2024
02624aa
Forward contentGraph workspace name to events
bwaidelich May 17, 2024
8140490
Fix behat tests
bwaidelich May 17, 2024
0f46361
Provide event migration
bwaidelich May 17, 2024
ded6c13
Remove unused namespace imports and add missing type annotation
bwaidelich May 17, 2024
4f3dcc5
Remove obsolete todo comment
bwaidelich May 17, 2024
d4f40e3
Fix event migration
bwaidelich May 17, 2024
b4e533d
Tweak event migration
bwaidelich May 17, 2024
7db53b6
Merge remote-tracking branch 'origin/9.0' into feature/4996-add-works…
mhsdesign May 17, 2024
f635c9e
TASK: Use `$contentGraph->getContentStreamId()` instead of from `$nod…
mhsdesign May 17, 2024
eabb990
Add workspaceName to all relevant events in behat tests
bwaidelich May 18, 2024
104b2a1
Merge branch '9.0' into feature/4996-add-workspacename-to-events
bwaidelich May 18, 2024
a545c21
Fix namespace import in TetheredNodeAdjustments
bwaidelich May 18, 2024
7d97ebc
Add more workspaceNames to tests..
bwaidelich May 18, 2024
e47bac8
Fix typo in behat test
bwaidelich May 18, 2024
7caba3c
one more "workspaceName"...
bwaidelich May 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
class PerformanceMeasurementService implements ContentRepositoryServiceInterface
{
private ContentStreamId $contentStreamId;
private WorkspaceName $workspaceName;
private DimensionSpacePointSet $dimensionSpacePoints;
private ContentStreamEventStreamName $contentStreamEventStream;

Expand All @@ -55,6 +56,7 @@ public function __construct(
private readonly ContentRepositoryId $contentRepositoryId
) {
$this->contentStreamId = contentStreamId::fromString('cs-identifier');
$this->workspaceName = WorkspaceName::fromString('some-workspace');
$this->dimensionSpacePoints = new DimensionSpacePointSet([
DimensionSpacePoint::fromArray(['language' => 'mul']),
DimensionSpacePoint::fromArray(['language' => 'de']),
Expand Down Expand Up @@ -86,6 +88,7 @@ public function createNodesForPerformanceTest(int $nodesPerLevel, int $levels):

$rootNodeAggregateId = nodeAggregateId::fromString('lady-eleonode-rootford');
$rootNodeAggregateWasCreated = new RootNodeAggregateWithNodeWasCreated(
$this->workspaceName,
$this->contentStreamId,
$rootNodeAggregateId,
NodeTypeName::fromString('Neos.ContentRepository:Root'),
Expand Down Expand Up @@ -129,6 +132,7 @@ private function createHierarchy(
for ($i = 0; $i < $numberOfNodes; $i++) {
$nodeAggregateId = nodeAggregateId::create();
$events[] = new NodeAggregateWithNodeWasCreated(
$this->workspaceName,
$this->contentStreamId,
$nodeAggregateId,
NodeTypeName::fromString('Neos.ContentRepository:Testing'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ public function denormalize(Event $event): EventInterface
$eventInstance = $eventClassName::fromArray($eventDataAsArray);
return match ($eventInstance::class) {
// upcast disabled / enabled events to the corresponding SubtreeTag events
NodeAggregateWasDisabled::class => new SubtreeWasTagged($eventInstance->contentStreamId, $eventInstance->nodeAggregateId, $eventInstance->affectedDimensionSpacePoints, SubtreeTag::disabled()),
NodeAggregateWasEnabled::class => new SubtreeWasUntagged($eventInstance->contentStreamId, $eventInstance->nodeAggregateId, $eventInstance->affectedDimensionSpacePoints, SubtreeTag::disabled()),
NodeAggregateWasDisabled::class => new SubtreeWasTagged($eventInstance->workspaceName, $eventInstance->contentStreamId, $eventInstance->nodeAggregateId, $eventInstance->affectedDimensionSpacePoints, SubtreeTag::disabled()),
NodeAggregateWasEnabled::class => new SubtreeWasUntagged($eventInstance->workspaceName, $eventInstance->contentStreamId, $eventInstance->nodeAggregateId, $eventInstance->affectedDimensionSpacePoints, SubtreeTag::disabled()),
default => $eventInstance,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ public static function enrichWithCommand(
foreach ($events as $event) {
if ($event instanceof DecoratedEvent) {
$undecoratedEvent = $event->innerEvent;
if (!$undecoratedEvent instanceof PublishableToOtherContentStreamsInterface) {
if (!$undecoratedEvent instanceof PublishableToWorkspaceInterface) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed the interface PublishableToOtherContentStreamsInterface to PublishableToWorkspaceInterface

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yes that was missed with bernhards change :D

throw new \RuntimeException(sprintf(
'TODO: Event %s has to implement PublishableToOtherContentStreamsInterface',
get_class($event)
));
}
} elseif (!$event instanceof PublishableToOtherContentStreamsInterface) {
} elseif (!$event instanceof PublishableToWorkspaceInterface) {
throw new \RuntimeException(sprintf(
'TODO: Event %s has to implement PublishableToOtherContentStreamsInterface',
get_class($event)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

namespace Neos\ContentRepository\Core\Feature\Common;

use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\DimensionSpace;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet;
use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint;
Expand All @@ -28,7 +27,6 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\NodeAggregate;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;

/**
* @internal implementation details of command handlers
Expand Down Expand Up @@ -102,6 +100,7 @@ protected function collectNodeSpecializationVariantsThatWillHaveBeenCreated(
array $events
): array {
$events[] = new NodeSpecializationVariantWasCreated(
$contentGraph->getWorkspaceName(),
$contentGraph->getContentStreamId(),
$nodeAggregate->nodeAggregateId,
$sourceOrigin,
Expand Down Expand Up @@ -164,6 +163,7 @@ protected function collectNodeGeneralizationVariantsThatWillHaveBeenCreated(
array $events
): array {
$events[] = new NodeGeneralizationVariantWasCreated(
$contentGraph->getWorkspaceName(),
$contentGraph->getContentStreamId(),
$nodeAggregate->nodeAggregateId,
$sourceOrigin,
Expand Down Expand Up @@ -226,6 +226,7 @@ protected function collectNodePeerVariantsThatWillHaveBeenCreated(
array $events
): array {
$events[] = new NodePeerVariantWasCreated(
$contentGraph->getWorkspaceName(),
$contentGraph->getContentStreamId(),
$nodeAggregate->nodeAggregateId,
$sourceOrigin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@
namespace Neos\ContentRepository\Core\Feature\Common;

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

/**
* This interface is implemented by **events** which can be published to different content streams.
* This interface is implemented by **events** which can be published to different workspaces.
*
* Reminder: Event Publishing to a target content stream can not fail if the source content stream is based
* on the target content stream, and no events have been committed to the target content stream in
* the meantime. This is because event's effects have to be fully deterministic.
*
* @internal used internally for the publishing mechanism of content streams
* @internal used internally for the publishing mechanism of workspaces
*/
interface PublishableToOtherContentStreamsInterface
interface PublishableToWorkspaceInterface
{
public function createCopyForContentStream(ContentStreamId $targetContentStreamId): self;
public function withWorkspaceNameAndContentStreamId(WorkspaceName $targetWorkspaceName, ContentStreamId $contentStreamId): self;
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ protected function createEventsForMissingTetheredNode(
$rootGeneralizationOrigin = OriginDimensionSpacePoint::fromDimensionSpacePoint($rootGeneralization);
if ($creationOriginDimensionSpacePoint) {
$events[] = new NodePeerVariantWasCreated(
$parentNodeAggregate->contentStreamId,
$contentGraph->getWorkspaceName(),
$contentGraph->getContentStreamId(),
$tetheredNodeAggregateId,
$creationOriginDimensionSpacePoint,
$rootGeneralizationOrigin,
Expand All @@ -91,7 +92,8 @@ protected function createEventsForMissingTetheredNode(
);
} else {
$events[] = new NodeAggregateWithNodeWasCreated(
$parentNodeAggregate->contentStreamId,
$contentGraph->getWorkspaceName(),
$contentGraph->getContentStreamId(),
$tetheredNodeAggregateId,
$tetheredNodeTypeDefinition->nodeTypeName,
$rootGeneralizationOrigin,
Expand All @@ -107,44 +109,43 @@ protected function createEventsForMissingTetheredNode(
}
}
return Events::fromArray($events);
} else {
return Events::with(
new NodeAggregateWithNodeWasCreated(
$parentNodeAggregate->contentStreamId,
$tetheredNodeAggregateId ?: NodeAggregateId::create(),
$tetheredNodeTypeDefinition->nodeTypeName,
$originDimensionSpacePoint,
InterdimensionalSiblings::fromDimensionSpacePointSetWithoutSucceedingSiblings(
$parentNodeAggregate->getCoverageByOccupant($originDimensionSpacePoint)
),
$parentNodeAggregate->nodeAggregateId,
$tetheredNodeTypeDefinition->name,
$defaultProperties,
NodeAggregateClassification::CLASSIFICATION_TETHERED,
)
);
}
} else {
if (!$childNodeAggregate->classification->isTethered()) {
throw new \RuntimeException(
'We found a child node aggregate through the given node path; but it is not tethered.'
. ' We do not support re-tethering yet'
. ' (as this case should happen very rarely as far as we think).'
);
}

$childNodeSource = null;
foreach ($childNodeAggregate->getNodes() as $node) {
$childNodeSource = $node;
break;
}
/** @var Node $childNodeSource Node aggregates are never empty */
return $this->createEventsForVariations(
$contentGraph,
$childNodeSource->originDimensionSpacePoint,
$originDimensionSpacePoint,
$parentNodeAggregate
return Events::with(
new NodeAggregateWithNodeWasCreated(
$contentGraph->getWorkspaceName(),
$contentGraph->getContentStreamId(),
$tetheredNodeAggregateId ?: NodeAggregateId::create(),
$tetheredNodeTypeDefinition->nodeTypeName,
$originDimensionSpacePoint,
InterdimensionalSiblings::fromDimensionSpacePointSetWithoutSucceedingSiblings(
$parentNodeAggregate->getCoverageByOccupant($originDimensionSpacePoint)
),
$parentNodeAggregate->nodeAggregateId,
$tetheredNodeTypeDefinition->name,
$defaultProperties,
NodeAggregateClassification::CLASSIFICATION_TETHERED,
)
);
}
if (!$childNodeAggregate->classification->isTethered()) {
throw new \RuntimeException(
'We found a child node aggregate through the given node path; but it is not tethered.'
. ' We do not support re-tethering yet'
. ' (as this case should happen very rarely as far as we think).'
);
}

$childNodeSource = null;
foreach ($childNodeAggregate->getNodes() as $node) {
$childNodeSource = $node;
break;
}
/** @var Node $childNodeSource Node aggregates are never empty */
return $this->createEventsForVariations(
$contentGraph,
$childNodeSource->originDimensionSpacePoint,
$originDimensionSpacePoint,
$parentNodeAggregate
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ private function handleMoveDimensionSpacePoint(
$streamName,
Events::with(
new DimensionSpacePointWasMoved(
$contentGraph->getWorkspaceName(),
$contentGraph->getContentStreamId(),
$command->source,
$command->target
Expand Down Expand Up @@ -108,6 +109,7 @@ private function handleAddDimensionShineThrough(
$streamName,
Events::with(
new DimensionShineThroughWasAdded(
$contentGraph->getWorkspaceName(),
$contentGraph->getContentStreamId(),
$command->source,
$command->target
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentRepository\Core\EventStore\EventInterface;
use Neos\ContentRepository\Core\Feature\Common\PublishableToOtherContentStreamsInterface;
use Neos\ContentRepository\Core\Feature\Common\PublishableToWorkspaceInterface;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;

/**
* Add a Dimension Space Point Shine-Through;
Expand All @@ -32,19 +33,21 @@
*
* @api events are the persistence-API of the content repository
*/
final readonly class DimensionShineThroughWasAdded implements EventInterface, PublishableToOtherContentStreamsInterface
final readonly class DimensionShineThroughWasAdded implements EventInterface, PublishableToWorkspaceInterface
{
public function __construct(
public WorkspaceName $workspaceName,
public ContentStreamId $contentStreamId,
public DimensionSpacePoint $source,
public DimensionSpacePoint $target
) {
}

public function createCopyForContentStream(ContentStreamId $targetContentStreamId): self
public function withWorkspaceNameAndContentStreamId(WorkspaceName $targetWorkspaceName, ContentStreamId $contentStreamId): self
{
return new self(
$targetContentStreamId,
$targetWorkspaceName,
$contentStreamId,
$this->source,
$this->target
);
Expand All @@ -53,6 +56,7 @@ public function createCopyForContentStream(ContentStreamId $targetContentStreamI
public static function fromArray(array $values): self
{
return new self(
WorkspaceName::fromString($values['workspaceName']),
ContentStreamId::fromString($values['contentStreamId']),
DimensionSpacePoint::fromArray($values['source']),
DimensionSpacePoint::fromArray($values['target'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentRepository\Core\EventStore\EventInterface;
use Neos\ContentRepository\Core\Feature\Common\PublishableToOtherContentStreamsInterface;
use Neos\ContentRepository\Core\Feature\Common\PublishableToWorkspaceInterface;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;

/**
* Moved a dimension space point to a new location; basically moving all content to the new dimension space point.
Expand All @@ -28,19 +29,21 @@
*
* @api events are the persistence-API of the content repository
*/
final readonly class DimensionSpacePointWasMoved implements EventInterface, PublishableToOtherContentStreamsInterface
final readonly class DimensionSpacePointWasMoved implements EventInterface, PublishableToWorkspaceInterface
{
public function __construct(
public WorkspaceName $workspaceName,
public ContentStreamId $contentStreamId,
public DimensionSpacePoint $source,
public DimensionSpacePoint $target
) {
}

public function createCopyForContentStream(ContentStreamId $targetContentStreamId): self
public function withWorkspaceNameAndContentStreamId(WorkspaceName $targetWorkspaceName, ContentStreamId $contentStreamId): self
{
return new self(
$targetContentStreamId,
$targetWorkspaceName,
$contentStreamId,
$this->source,
$this->target
);
Expand All @@ -49,6 +52,7 @@ public function createCopyForContentStream(ContentStreamId $targetContentStreamI
public static function fromArray(array $values): self
{
return new self(
WorkspaceName::fromString($values['workspaceName']),
ContentStreamId::fromString($values['contentStreamId']),
DimensionSpacePoint::fromArray($values['source']),
DimensionSpacePoint::fromArray($values['target'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
use Neos\ContentRepository\Core\EventStore\EventInterface;
use Neos\ContentRepository\Core\Feature\Common\EmbedsContentStreamAndNodeAggregateId;
use Neos\ContentRepository\Core\Feature\Common\InterdimensionalSiblings;
use Neos\ContentRepository\Core\Feature\Common\PublishableToOtherContentStreamsInterface;
use Neos\ContentRepository\Core\Feature\Common\PublishableToWorkspaceInterface;
use Neos\ContentRepository\Core\Feature\NodeModification\Dto\SerializedPropertyValues;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateClassification;
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;

/**
* A node aggregate with its initial node was created
Expand All @@ -34,10 +35,11 @@
*/
final readonly class NodeAggregateWithNodeWasCreated implements
EventInterface,
PublishableToOtherContentStreamsInterface,
PublishableToWorkspaceInterface,
EmbedsContentStreamAndNodeAggregateId
{
public function __construct(
public WorkspaceName $workspaceName,
public ContentStreamId $contentStreamId,
public NodeAggregateId $nodeAggregateId,
public NodeTypeName $nodeTypeName,
Expand Down Expand Up @@ -65,10 +67,11 @@ public function getOriginDimensionSpacePoint(): OriginDimensionSpacePoint
return $this->originDimensionSpacePoint;
}

public function createCopyForContentStream(ContentStreamId $targetContentStreamId): self
public function withWorkspaceNameAndContentStreamId(WorkspaceName $targetWorkspaceName, ContentStreamId $contentStreamId): self
{
return new self(
$targetContentStreamId,
$targetWorkspaceName,
$contentStreamId,
$this->nodeAggregateId,
$this->nodeTypeName,
$this->originDimensionSpacePoint,
Expand All @@ -83,6 +86,7 @@ public function createCopyForContentStream(ContentStreamId $targetContentStreamI
public static function fromArray(array $values): self
{
return new self(
WorkspaceName::fromString($values['workspaceName']),
ContentStreamId::fromString($values['contentStreamId']),
NodeAggregateId::fromString($values['nodeAggregateId']),
NodeTypeName::fromString($values['nodeTypeName']),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ private function createRegularWithNode(
SerializedPropertyValues $initialPropertyValues,
): NodeAggregateWithNodeWasCreated {
return new NodeAggregateWithNodeWasCreated(
$contentGraph->getWorkspaceName(),
$contentGraph->getContentStreamId(),
$command->nodeAggregateId,
$command->nodeTypeName,
Expand Down Expand Up @@ -277,6 +278,7 @@ private function handleTetheredChildNodes(
);

$events[] = new NodeAggregateWithNodeWasCreated(
$contentGraph->getWorkspaceName(),
$contentGraph->getContentStreamId(),
$childNodeAggregateId,
$tetheredNodeTypeDefinition->nodeTypeName,
Expand Down
Loading
Loading