-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathFromStateDoesNotReturnAnAggregate.php
93 lines (76 loc) · 2.13 KB
/
FromStateDoesNotReturnAnAggregate.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
<?php
namespace TalisOrm\AggregateRepositoryTest;
use Doctrine\DBAL\Schema\Schema;
use stdClass;
use TalisOrm\Aggregate;
use TalisOrm\AggregateId;
use TalisOrm\DomainEvents\EventRecordingCapabilities;
use TalisOrm\Schema\SpecifiesSchema;
use Webmozart\Assert\Assert;
final class FromStateDoesNotReturnAnAggregate implements Aggregate, SpecifiesSchema
{
use EventRecordingCapabilities;
/**
* @var FromStateDoesNotReturnAnAggregateId
*/
private $aggregateId;
public function __construct(FromStateDoesNotReturnAnAggregateId $aggregateId)
{
$this->aggregateId = $aggregateId;
}
public function childEntitiesByType(): array
{
return [];
}
public static function childEntityTypes(): array
{
return [];
}
public function state(): array
{
return [
'aggregate_id' => $this->aggregateId->id()
];
}
public static function fromState(array $aggregateState, array $childEntityStatesByType)
{
// Note: not an instance of this aggregate class
return new stdClass();
}
public static function tableName(): string
{
return 'from_state_does_not_return_an_aggregate';
}
public function identifier(): array
{
return [
'aggregate_id' => $this->aggregateId->id()
];
}
public static function identifierForQuery(AggregateId $aggregateId): array
{
Assert::isInstanceOf($aggregateId, FromStateDoesNotReturnAnAggregateId::class);
/** @var FromStateDoesNotReturnAnAggregateId $aggregateId */
return [
'aggregate_id' => $aggregateId->id()
];
}
public function deletedChildEntities(): array
{
return [];
}
public static function specifySchema(Schema $schema): void
{
$table = $schema->createTable('from_state_does_not_return_an_aggregate');
$table->addColumn('aggregate_id', 'integer');
$table->addUniqueIndex(['aggregate_id']);
}
public function isNew(): bool
{
return true;
}
public function markAsPersisted(): void
{
// do nothing
}
}