Skip to content

Commit

Permalink
Draft: FEATURE: Put initiating user id and creation date into event m…
Browse files Browse the repository at this point in the history
…etadata

Resolves: #3874
  • Loading branch information
bwaidelich committed Sep 1, 2022
1 parent 82531cc commit 8abb003
Show file tree
Hide file tree
Showing 26 changed files with 76 additions and 328 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
namespace Neos\ContentRepository\Core\Feature\ContentStreamCreation\Event;

use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\User\UserId;
use Neos\ContentRepository\Core\EventStore\EventInterface;

/**
Expand All @@ -28,23 +27,18 @@ final class ContentStreamWasCreated implements EventInterface
{
public function __construct(
public readonly ContentStreamId $contentStreamId,
public readonly UserId $initiatingUserId
) {
}

public static function fromArray(array $values): self
{
return new self(
ContentStreamId::fromString($values['contentStreamId']),
UserId::fromString($values['initiatingUserId']),
);
}

public function jsonSerialize(): array
{
return [
'contentStreamId' => $this->contentStreamId,
'initiatingUserId' => $this->initiatingUserId,
];
return get_object_vars($this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

use Neos\ContentRepository\Core\EventStore\EventInterface;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\User\UserId;
use Neos\EventStore\Model\Event\Version;

/**
Expand All @@ -31,7 +30,6 @@ public function __construct(
public readonly ContentStreamId $newContentStreamId,
public readonly ContentStreamId $sourceContentStreamId,
public readonly Version $versionOfSourceContentStream,
public readonly UserId $initiatingUserId
) {
}

Expand All @@ -41,17 +39,11 @@ public static function fromArray(array $values): self
ContentStreamId::fromString($values['newContentStreamId']),
ContentStreamId::fromString($values['sourceContentStreamId']),
Version::fromInteger($values['versionOfSourceContentStream']),
UserId::fromString($values['initiatingUserId']),
);
}

public function jsonSerialize(): array
{
return [
'newContentStreamId' => $this->newContentStreamId,
'sourceContentStreamId' => $this->sourceContentStreamId,
'versionOfSourceContentStream' => $this->versionOfSourceContentStream->value,
'initiatingUserId' => $this->initiatingUserId,
];
return get_object_vars($this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
* source code.
*/

use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\User\UserId;
use Neos\ContentRepository\Core\EventStore\EventInterface;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;

/**
* @api events are the persistence-API of the content repository
Expand All @@ -25,23 +24,18 @@ final class ContentStreamWasRemoved implements EventInterface
{
public function __construct(
public readonly ContentStreamId $contentStreamId,
public readonly UserId $initiatingUserId
) {
}

public static function fromArray(array $values): self
{
return new self(
ContentStreamId::fromString($values['contentStreamId']),
UserId::fromString($values['initiatingUserId']),
);
}

public function jsonSerialize(): array
{
return [
'contentStreamId' => $this->contentStreamId,
'initiatingUserId' => $this->initiatingUserId,
];
return get_object_vars($this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ public static function fromArray(array $values): self

public function jsonSerialize(): array
{
return [
'contentStreamId' => $this->contentStreamId,
'source' => $this->source,
'target' => $this->target,
];
return get_object_vars($this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ public static function fromArray(array $values): self

public function jsonSerialize(): array
{
return [
'contentStreamId' => $this->contentStreamId,
'source' => $this->source,
'target' => $this->target,
];
return get_object_vars($this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public function __construct(
public readonly ?NodeName $nodeName,
public readonly SerializedPropertyValues $initialPropertyValues,
public readonly NodeAggregateClassification $nodeAggregateClassification,
public readonly UserId $initiatingUserId,
public readonly ?NodeAggregateId $succeedingNodeAggregateId = null
) {
}
Expand Down Expand Up @@ -79,7 +78,6 @@ public function createCopyForContentStream(ContentStreamId $targetContentStreamI
$this->nodeName,
$this->initialPropertyValues,
$this->nodeAggregateClassification,
$this->initiatingUserId,
$this->succeedingNodeAggregateId
);
}
Expand All @@ -96,7 +94,6 @@ public static function fromArray(array $values): self
isset($values['nodeName']) ? NodeName::fromString($values['nodeName']) : null,
SerializedPropertyValues::fromArray($values['initialPropertyValues']),
NodeAggregateClassification::from($values['nodeAggregateClassification']),
UserId::fromString($values['initiatingUserId']),
isset($values['succeedingNodeAggregateId'])
? NodeAggregateId::fromString($values['succeedingNodeAggregateId'])
: null,
Expand All @@ -105,18 +102,6 @@ public static function fromArray(array $values): self

public function jsonSerialize(): array
{
return [
'contentStreamId' => $this->contentStreamId,
'nodeAggregateId' => $this->nodeAggregateId,
'nodeTypeName' => $this->nodeTypeName,
'originDimensionSpacePoint' => $this->originDimensionSpacePoint,
'coveredDimensionSpacePoints' => $this->coveredDimensionSpacePoints,
'parentNodeAggregateId' => $this->parentNodeAggregateId,
'nodeName' => $this->nodeName,
'initialPropertyValues' => $this->initialPropertyValues,
'nodeAggregateClassification' => $this->nodeAggregateClassification,
'initiatingUserId' => $this->initiatingUserId,
'succeedingNodeAggregateId' => $this->succeedingNodeAggregateId
];
return get_object_vars($this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
namespace Neos\ContentRepository\Core\Feature\NodeDisabling\Event;

use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\EventStore\EventInterface;
use Neos\ContentRepository\Core\Feature\Common\EmbedsContentStreamAndNodeAggregateId;
use Neos\ContentRepository\Core\Feature\Common\PublishableToOtherContentStreamsInterface;
use Neos\ContentRepository\Core\SharedModel\User\UserId;
use Neos\ContentRepository\Core\EventStore\EventInterface;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;

/**
* A node aggregate was disabled
Expand All @@ -37,7 +36,6 @@ public function __construct(
public readonly NodeAggregateId $nodeAggregateId,
/** The dimension space points the node aggregate was disabled in */
public readonly DimensionSpacePointSet $affectedDimensionSpacePoints,
public readonly UserId $initiatingUserId
) {
}

Expand All @@ -57,7 +55,6 @@ public function createCopyForContentStream(ContentStreamId $targetContentStreamI
$targetContentStreamId,
$this->nodeAggregateId,
$this->affectedDimensionSpacePoints,
$this->initiatingUserId
);
}

Expand All @@ -67,17 +64,11 @@ public static function fromArray(array $values): EventInterface
ContentStreamId::fromString($values['contentStreamId']),
NodeAggregateId::fromString($values['nodeAggregateId']),
DimensionSpacePointSet::fromArray($values['affectedDimensionSpacePoints']),
UserId::fromString($values['initiatingUserId'])
);
}

public function jsonSerialize(): array
{
return [
'contentStreamId' => $this->contentStreamId,
'nodeAggregateId' => $this->nodeAggregateId,
'affectedDimensionSpacePoints' => $this->affectedDimensionSpacePoints,
'initiatingUserId' => $this->initiatingUserId
];
return get_object_vars($this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
namespace Neos\ContentRepository\Core\Feature\NodeDisabling\Event;

use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\EventStore\EventInterface;
use Neos\ContentRepository\Core\Feature\Common\EmbedsContentStreamAndNodeAggregateId;
use Neos\ContentRepository\Core\Feature\Common\PublishableToOtherContentStreamsInterface;
use Neos\ContentRepository\Core\SharedModel\User\UserId;
use Neos\ContentRepository\Core\EventStore\EventInterface;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;

/**
* A node aggregate was enabled
Expand All @@ -36,7 +35,6 @@ public function __construct(
public readonly ContentStreamId $contentStreamId,
public readonly NodeAggregateId $nodeAggregateId,
public readonly DimensionSpacePointSet $affectedDimensionSpacePoints,
public readonly UserId $initiatingUserId
) {
}

Expand All @@ -56,7 +54,6 @@ public function createCopyForContentStream(ContentStreamId $targetContentStreamI
$targetContentStreamId,
$this->nodeAggregateId,
$this->affectedDimensionSpacePoints,
$this->initiatingUserId
);
}

Expand All @@ -66,17 +63,11 @@ public static function fromArray(array $values): EventInterface
ContentStreamId::fromString($values['contentStreamId']),
NodeAggregateId::fromString($values['nodeAggregateId']),
DimensionSpacePointSet::fromArray($values['affectedDimensionSpacePoints']),
UserId::fromString($values['initiatingUserId'])
);
}

public function jsonSerialize(): array
{
return [
'contentStreamId' => $this->contentStreamId,
'nodeAggregateId' => $this->nodeAggregateId,
'affectedDimensionSpacePoints' => $this->affectedDimensionSpacePoints,
'initiatingUserId' => $this->initiatingUserId
];
return get_object_vars($this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@

namespace Neos\ContentRepository\Core\Feature\NodeModification\Event;

use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint;
use Neos\ContentRepository\Core\EventStore\EventInterface;
use Neos\ContentRepository\Core\Feature\Common\EmbedsContentStreamAndNodeAggregateId;
use Neos\ContentRepository\Core\Feature\Common\PublishableToOtherContentStreamsInterface;
use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint;
use Neos\ContentRepository\Core\Feature\NodeModification\Dto\SerializedPropertyValues;
use Neos\ContentRepository\Core\SharedModel\User\UserId;
use Neos\ContentRepository\Core\EventStore\EventInterface;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;

/**
* When a node property is changed, this event is triggered.
Expand All @@ -34,19 +33,9 @@
*
* @api events are the persistence-API of the content repository
*/
final class NodePropertiesWereSet implements
EventInterface,
PublishableToOtherContentStreamsInterface,
EmbedsContentStreamAndNodeAggregateId
final class NodePropertiesWereSet implements EventInterface, PublishableToOtherContentStreamsInterface, EmbedsContentStreamAndNodeAggregateId
{
public function __construct(
public readonly ContentStreamId $contentStreamId,
public readonly NodeAggregateId $nodeAggregateId,
public readonly OriginDimensionSpacePoint $originDimensionSpacePoint,
public readonly SerializedPropertyValues $propertyValues,
public readonly UserId $initiatingUserId
) {
}
public function __construct(public readonly ContentStreamId $contentStreamId, public readonly NodeAggregateId $nodeAggregateId, public readonly OriginDimensionSpacePoint $originDimensionSpacePoint, public readonly SerializedPropertyValues $propertyValues,) {}

public function getContentStreamId(): ContentStreamId
{
Expand All @@ -65,45 +54,21 @@ public function getOriginDimensionSpacePoint(): OriginDimensionSpacePoint

public function createCopyForContentStream(ContentStreamId $targetContentStreamId): self
{
return new self(
$targetContentStreamId,
$this->nodeAggregateId,
$this->originDimensionSpacePoint,
$this->propertyValues,
$this->initiatingUserId
);
return new self($targetContentStreamId, $this->nodeAggregateId, $this->originDimensionSpacePoint, $this->propertyValues);
}

public function mergeProperties(self $other): self
{
return new self(
$this->contentStreamId,
$this->nodeAggregateId,
$this->originDimensionSpacePoint,
$this->propertyValues->merge($other->propertyValues),
$this->initiatingUserId
);
return new self($this->contentStreamId, $this->nodeAggregateId, $this->originDimensionSpacePoint, $this->propertyValues->merge($other->propertyValues), $this->initiatingUserId);
}

public static function fromArray(array $values): EventInterface
{
return new self(
ContentStreamId::fromString($values['contentStreamId']),
NodeAggregateId::fromString($values['nodeAggregateId']),
OriginDimensionSpacePoint::fromArray($values['originDimensionSpacePoint']),
SerializedPropertyValues::fromArray($values['propertyValues']),
UserId::fromString($values['initiatingUserId'])
);
return new self(ContentStreamId::fromString($values['contentStreamId']), NodeAggregateId::fromString($values['nodeAggregateId']), OriginDimensionSpacePoint::fromArray($values['originDimensionSpacePoint']), SerializedPropertyValues::fromArray($values['propertyValues']),);
}

public function jsonSerialize(): array
{
return [
'contentStreamId' => $this->contentStreamId,
'nodeAggregateId' => $this->nodeAggregateId,
'originDimensionSpacePoint' => $this->originDimensionSpacePoint,
'propertyValues' => $this->propertyValues,
'initiatingUserId' => $this->initiatingUserId
];
return get_object_vars($this);
}
}
Loading

0 comments on commit 8abb003

Please sign in to comment.