-
Notifications
You must be signed in to change notification settings - Fork 9
/
OrderTalisOrmRepository.php
44 lines (36 loc) · 1.07 KB
/
OrderTalisOrmRepository.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
<?php
namespace TalisOrm\AggregateRepositoryTest;
use TalisOrm\AggregateRepository;
/**
* This is your implementation of the OrderRepository interface from your _Domain_ layer. This implementation itself
* belongs to the _Infrastructure_ layer.
*/
final class OrderTalisOrmRepository implements OrderRepository
{
/**
* @phpstan-var AggregateRepository<Order>
*/
private $aggregateRepository;
/**
* @phpstan-param AggregateRepository<Order> $aggregateRepository
*/
public function __construct(AggregateRepository $aggregateRepository)
{
$this->aggregateRepository = $aggregateRepository;
}
public function save(Order $order)
{
$this->aggregateRepository->save($order);
// you may dispatch events at this point
}
public function getById(OrderId $orderId)
{
return $this->aggregateRepository->getById(Order::class, $orderId, [
'quantityPrecision' => 2
]);
}
public function delete(Order $order)
{
$this->aggregateRepository->delete($order);
}
}