1 | <?php |
||
29 | class Repository implements RepositoryInterface |
||
30 | { |
||
31 | /** |
||
32 | * @var StorageInterface |
||
33 | */ |
||
34 | private $storage; |
||
35 | |||
36 | /** |
||
37 | * @var SnapshotInterface |
||
38 | */ |
||
39 | private $snapshot; |
||
40 | |||
41 | /** |
||
42 | * @var BusProxy |
||
43 | */ |
||
44 | private $eventBus; |
||
45 | |||
46 | /** |
||
47 | * @var string |
||
48 | */ |
||
49 | private $aggregateRootClass; |
||
50 | |||
51 | /** |
||
52 | * @var string |
||
53 | */ |
||
54 | private $table; |
||
55 | |||
56 | /** |
||
57 | * Constructor. |
||
58 | * |
||
59 | * @param StorageInterface $storage |
||
60 | * @param BusProxy $eventBus |
||
61 | * @param string $aggregateRootClass |
||
62 | * @param string $table |
||
63 | */ |
||
64 | public function __construct(StorageInterface $storage, BusProxy $eventBus, $aggregateRootClass, $table) |
||
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | */ |
||
76 | public function persist(AggregateRootInterface $aggregateRoot) |
||
90 | |||
91 | /** |
||
92 | * {@inheritdoc} |
||
93 | */ |
||
94 | public function find(IdentifierInterface $id) |
||
112 | |||
113 | /** |
||
114 | * Publish domain events in stream. |
||
115 | * |
||
116 | * @param DomainEventStreamInterface $stream |
||
117 | * |
||
118 | * @return array |
||
119 | * @throws \Exception |
||
120 | */ |
||
121 | private function publish(DomainEventStreamInterface $stream) |
||
145 | |||
146 | /** |
||
147 | * Broadcast event. |
||
148 | * |
||
149 | * @param DomainEventInterface $event |
||
150 | * @param array $metadata |
||
151 | */ |
||
152 | private function broadcast(DomainEventInterface $event, array $metadata) |
||
158 | |||
159 | /** |
||
160 | * Assert that aggregate root should be instance of $className |
||
161 | * |
||
162 | * @param AggregateRootInterface $aggregateRoot |
||
163 | * @param string $className |
||
164 | */ |
||
165 | private function assertInstanceOf(AggregateRootInterface $aggregateRoot, $className) |
||
175 | } |
||
176 |