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 1 commit
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Expand Up @@ -172,8 +172,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
Expand Up @@ -16,6 +16,7 @@

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

/**
* This interface is implemented by **events** which contain ContentStreamId and NodeAggregateId.
Expand All @@ -26,6 +27,7 @@
*/
interface EmbedsContentStreamAndNodeAggregateId
{
public function getWorkspaceName(): WorkspaceName;
public function getContentStreamId(): ContentStreamId;
public function getNodeAggregateId(): NodeAggregateId;
}
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 PublishableInterface) {
throw new \RuntimeException(sprintf(
'TODO: Event %s has to implement PublishableToOtherContentStreamsInterface',
get_class($event)
));
}
} elseif (!$event instanceof PublishableToOtherContentStreamsInterface) {
} elseif (!$event instanceof PublishableInterface) {
throw new \RuntimeException(sprintf(
'TODO: Event %s has to implement PublishableToOtherContentStreamsInterface',
get_class($event)
Expand Down
Expand Up @@ -24,11 +24,11 @@
use Neos\ContentRepository\Core\Feature\NodeVariation\Event\NodePeerVariantWasCreated;
use Neos\ContentRepository\Core\Feature\NodeVariation\Event\NodeSpecializationVariantWasCreated;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindSucceedingSiblingNodesFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
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\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;

/**
* @internal implementation details of command handlers
Expand All @@ -38,6 +38,7 @@ trait NodeVariationInternals
abstract protected function getInterDimensionalVariationGraph(): DimensionSpace\InterDimensionalVariationGraph;

protected function createEventsForVariations(
WorkspaceName $workspaceName,
ContentStreamId $contentStreamId,
OriginDimensionSpacePoint $sourceOrigin,
OriginDimensionSpacePoint $targetOrigin,
Expand All @@ -51,20 +52,23 @@ protected function createEventsForVariations(
)
) {
DimensionSpace\VariantType::TYPE_SPECIALIZATION => $this->handleCreateNodeSpecializationVariant(
$workspaceName,
$contentStreamId,
$sourceOrigin,
$targetOrigin,
$nodeAggregate,
$contentRepository
),
DimensionSpace\VariantType::TYPE_GENERALIZATION => $this->handleCreateNodeGeneralizationVariant(
$workspaceName,
$contentStreamId,
$sourceOrigin,
$targetOrigin,
$nodeAggregate,
$contentRepository
),
default => $this->handleCreateNodePeerVariant(
$workspaceName,
$contentStreamId,
$sourceOrigin,
$targetOrigin,
Expand All @@ -75,6 +79,7 @@ protected function createEventsForVariations(
}

protected function handleCreateNodeSpecializationVariant(
WorkspaceName $workspaceName,
ContentStreamId $contentStreamId,
OriginDimensionSpacePoint $sourceOrigin,
OriginDimensionSpacePoint $targetOrigin,
Expand All @@ -83,6 +88,7 @@ protected function handleCreateNodeSpecializationVariant(
): Events {
$specializationVisibility = $this->calculateEffectiveVisibility($targetOrigin, $nodeAggregate);
$events = $this->collectNodeSpecializationVariantsThatWillHaveBeenCreated(
$workspaceName,
$contentStreamId,
$sourceOrigin,
$targetOrigin,
Expand All @@ -100,6 +106,7 @@ protected function handleCreateNodeSpecializationVariant(
* @return array<int,EventInterface>
*/
protected function collectNodeSpecializationVariantsThatWillHaveBeenCreated(
WorkspaceName $workspaceName,
ContentStreamId $contentStreamId,
OriginDimensionSpacePoint $sourceOrigin,
OriginDimensionSpacePoint $targetOrigin,
Expand All @@ -109,6 +116,7 @@ protected function collectNodeSpecializationVariantsThatWillHaveBeenCreated(
ContentRepository $contentRepository
): array {
$events[] = new NodeSpecializationVariantWasCreated(
$workspaceName,
$contentStreamId,
$nodeAggregate->nodeAggregateId,
$sourceOrigin,
Expand All @@ -129,6 +137,7 @@ protected function collectNodeSpecializationVariantsThatWillHaveBeenCreated(
) as $tetheredChildNodeAggregate
) {
$events = $this->collectNodeSpecializationVariantsThatWillHaveBeenCreated(
$workspaceName,
$contentStreamId,
$sourceOrigin,
$targetOrigin,
Expand All @@ -143,6 +152,7 @@ protected function collectNodeSpecializationVariantsThatWillHaveBeenCreated(
}

protected function handleCreateNodeGeneralizationVariant(
WorkspaceName $workspaceName,
ContentStreamId $contentStreamId,
OriginDimensionSpacePoint $sourceOrigin,
OriginDimensionSpacePoint $targetOrigin,
Expand All @@ -151,6 +161,7 @@ protected function handleCreateNodeGeneralizationVariant(
): Events {
$generalizationVisibility = $this->calculateEffectiveVisibility($targetOrigin, $nodeAggregate);
$events = $this->collectNodeGeneralizationVariantsThatWillHaveBeenCreated(
$workspaceName,
$contentStreamId,
$sourceOrigin,
$targetOrigin,
Expand All @@ -168,6 +179,7 @@ protected function handleCreateNodeGeneralizationVariant(
* @return array<int,EventInterface>
*/
protected function collectNodeGeneralizationVariantsThatWillHaveBeenCreated(
WorkspaceName $workspaceName,
ContentStreamId $contentStreamId,
OriginDimensionSpacePoint $sourceOrigin,
OriginDimensionSpacePoint $targetOrigin,
Expand All @@ -177,6 +189,7 @@ protected function collectNodeGeneralizationVariantsThatWillHaveBeenCreated(
ContentRepository $contentRepository
): array {
$events[] = new NodeGeneralizationVariantWasCreated(
$workspaceName,
$contentStreamId,
$nodeAggregate->nodeAggregateId,
$sourceOrigin,
Expand All @@ -197,6 +210,7 @@ protected function collectNodeGeneralizationVariantsThatWillHaveBeenCreated(
) as $tetheredChildNodeAggregate
) {
$events = $this->collectNodeGeneralizationVariantsThatWillHaveBeenCreated(
$workspaceName,
$contentStreamId,
$sourceOrigin,
$targetOrigin,
Expand All @@ -211,6 +225,7 @@ protected function collectNodeGeneralizationVariantsThatWillHaveBeenCreated(
}

protected function handleCreateNodePeerVariant(
WorkspaceName $workspaceName,
ContentStreamId $contentStreamId,
OriginDimensionSpacePoint $sourceOrigin,
OriginDimensionSpacePoint $targetOrigin,
Expand All @@ -219,6 +234,7 @@ protected function handleCreateNodePeerVariant(
): Events {
$peerVisibility = $this->calculateEffectiveVisibility($targetOrigin, $nodeAggregate);
$events = $this->collectNodePeerVariantsThatWillHaveBeenCreated(
$workspaceName,
$contentStreamId,
$sourceOrigin,
$targetOrigin,
Expand All @@ -236,6 +252,7 @@ protected function handleCreateNodePeerVariant(
* @return array<int,EventInterface>
*/
protected function collectNodePeerVariantsThatWillHaveBeenCreated(
WorkspaceName $workspaceName,
ContentStreamId $contentStreamId,
OriginDimensionSpacePoint $sourceOrigin,
OriginDimensionSpacePoint $targetOrigin,
Expand All @@ -245,6 +262,7 @@ protected function collectNodePeerVariantsThatWillHaveBeenCreated(
ContentRepository $contentRepository
): array {
$events[] = new NodePeerVariantWasCreated(
$workspaceName,
$contentStreamId,
$nodeAggregate->nodeAggregateId,
$sourceOrigin,
Expand All @@ -265,6 +283,7 @@ protected function collectNodePeerVariantsThatWillHaveBeenCreated(
) as $tetheredChildNodeAggregate
) {
$events = $this->collectNodePeerVariantsThatWillHaveBeenCreated(
$workspaceName,
$contentStreamId,
$sourceOrigin,
$targetOrigin,
Expand Down
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
*/
interface PublishableToOtherContentStreamsInterface
interface PublishableInterface
{
public function createCopyForContentStream(ContentStreamId $targetContentStreamId): self;
public function createCopyForContentStream(WorkspaceName $targetWorkspaceName, ContentStreamId $targetContentStreamId): self;
bwaidelich marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Up @@ -29,6 +29,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;

/**
* @internal implementation details of command handlers
Expand All @@ -40,6 +41,7 @@ trait TetheredNodeInternals
abstract protected function getPropertyConverter(): PropertyConverter;

abstract protected function createEventsForVariations(
WorkspaceName $workspaceName,
ContentStreamId $contentStreamId,
OriginDimensionSpacePoint $sourceOrigin,
OriginDimensionSpacePoint $targetOrigin,
Expand Down Expand Up @@ -88,6 +90,7 @@ protected function createEventsForMissingTetheredNode(
$rootGeneralizationOrigin = OriginDimensionSpacePoint::fromDimensionSpacePoint($rootGeneralization);
if ($creationOriginDimensionSpacePoint) {
$events[] = new NodePeerVariantWasCreated(
WorkspaceName::fromString('todo'), // TODO read from $parentNodeAggregate
$parentNodeAggregate->contentStreamId,
$tetheredNodeAggregateId,
$creationOriginDimensionSpacePoint,
Expand All @@ -98,6 +101,7 @@ protected function createEventsForMissingTetheredNode(
);
} else {
$events[] = new NodeAggregateWithNodeWasCreated(
WorkspaceName::fromString('todo'), // TODO read from $parentNodeAggregate
$parentNodeAggregate->contentStreamId,
$tetheredNodeAggregateId,
$expectedTetheredNodeType->name,
Expand All @@ -117,6 +121,7 @@ protected function createEventsForMissingTetheredNode(
} else {
return Events::with(
new NodeAggregateWithNodeWasCreated(
WorkspaceName::fromString('todo'), // TODO read from $parentNodeAggregate
$parentNodeAggregate->contentStreamId,
$tetheredNodeAggregateId ?: NodeAggregateId::create(),
$expectedTetheredNodeType->name,
Expand Down Expand Up @@ -149,6 +154,7 @@ protected function createEventsForMissingTetheredNode(
}
/** @var Node $childNodeSource Node aggregates are never empty */
return $this->createEventsForVariations(
WorkspaceName::fromString('todo'), // TODO read from $parentNodeAggregate
$parentNodeAggregate->contentStreamId,
$childNodeSource->originDimensionSpacePoint,
$originDimensionSpacePoint,
Expand Down
Expand Up @@ -82,6 +82,7 @@ private function handleMoveDimensionSpacePoint(
$streamName,
Events::with(
new DimensionSpacePointWasMoved(
$command->workspaceName,
$contentStreamId,
$command->source,
$command->target
Expand Down Expand Up @@ -112,6 +113,7 @@ private function handleAddDimensionShineThrough(
$streamName,
Events::with(
new DimensionShineThroughWasAdded(
$command->workspaceName,
$contentStreamId,
$command->source,
$command->target
Expand Down
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\PublishableInterface;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;

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

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

public function createCopyForContentStream(WorkspaceName $targetWorkspaceName, ContentStreamId $targetContentStreamId): self
{
return new self(
$targetWorkspaceName,
$targetContentStreamId,
$this->source,
$this->target
Expand All @@ -53,6 +61,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