1 | <?php |
||
24 | class TimeBasedSnapshottingPolicy implements SnapshottingPolicyInterface |
||
25 | { |
||
26 | /** |
||
27 | * @var SnapshotStoreInterface |
||
28 | */ |
||
29 | protected $snapshotStore; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $threshold; |
||
35 | |||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $aggregateClassName; |
||
40 | |||
41 | /** |
||
42 | * TimeBasedSnapshottingPolicy constructor. |
||
43 | * |
||
44 | * @param SnapshotStoreInterface $snapshotStore |
||
45 | * @param string $aggregateClassName |
||
46 | * @param string $threshold |
||
47 | */ |
||
48 | public function __construct(SnapshotStoreInterface $snapshotStore, $aggregateClassName, $threshold = '1 hour') |
||
55 | |||
56 | /** |
||
57 | * {@inheritdoc} |
||
58 | */ |
||
59 | public function shouldCreateSnapshot(EventSourcedAggregateRootInterface $eventSourcedAggregateRoot) |
||
74 | |||
75 | /** |
||
76 | * Load a aggregate snapshot from the storage. |
||
77 | * |
||
78 | * @param IdInterface $id |
||
79 | * |
||
80 | * @return Snapshot|null |
||
81 | */ |
||
82 | protected function loadSnapshot(IdInterface $id) |
||
86 | |||
87 | /** |
||
88 | * @return string |
||
89 | */ |
||
90 | protected function streamName(IdInterface $id) |
||
94 | } |
||
95 |