-
-
Notifications
You must be signed in to change notification settings - Fork 224
/
Copy pathRootNodeAggregateWithNodeWasCreated.php
95 lines (84 loc) · 3.29 KB
/
RootNodeAggregateWithNodeWasCreated.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
/*
* This file is part of the Neos.ContentRepository package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/
declare(strict_types=1);
namespace Neos\ContentRepository\Core\Feature\RootNodeCreation\Event;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet;
use Neos\ContentRepository\Core\EventStore\EventInterface;
use Neos\ContentRepository\Core\Feature\Common\EmbedsContentStreamId;
use Neos\ContentRepository\Core\Feature\Common\EmbedsNodeAggregateId;
use Neos\ContentRepository\Core\Feature\Common\EmbedsWorkspaceName;
use Neos\ContentRepository\Core\Feature\Common\PublishableToWorkspaceInterface;
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\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
/**
* A root node aggregate and its initial node were created
*
* @api events are the persistence-API of the content repository
*/
final readonly class RootNodeAggregateWithNodeWasCreated implements
EventInterface,
PublishableToWorkspaceInterface,
EmbedsContentStreamId,
EmbedsNodeAggregateId,
EmbedsWorkspaceName
{
public function __construct(
public WorkspaceName $workspaceName,
public ContentStreamId $contentStreamId,
public NodeAggregateId $nodeAggregateId,
public NodeTypeName $nodeTypeName,
/** Root nodes by definition cover *all* dimension space points; so we need to include the full list here. */
public DimensionSpacePointSet $coveredDimensionSpacePoints,
public NodeAggregateClassification $nodeAggregateClassification,
) {
}
public function getContentStreamId(): ContentStreamId
{
return $this->contentStreamId;
}
public function getNodeAggregateId(): NodeAggregateId
{
return $this->nodeAggregateId;
}
public function getWorkspaceName(): WorkspaceName
{
return $this->workspaceName;
}
public function withWorkspaceNameAndContentStreamId(WorkspaceName $targetWorkspaceName, ContentStreamId $contentStreamId): self
{
return new self(
$targetWorkspaceName,
$contentStreamId,
$this->nodeAggregateId,
$this->nodeTypeName,
$this->coveredDimensionSpacePoints,
$this->nodeAggregateClassification,
);
}
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']),
DimensionSpacePointSet::fromArray($values['coveredDimensionSpacePoints']),
NodeAggregateClassification::from($values['nodeAggregateClassification']),
);
}
public function jsonSerialize(): array
{
return get_object_vars($this);
}
}