1 | <?php |
||
5 | class EventSubscriber |
||
6 | { |
||
7 | /** @var \Spatie\EventProjector\Projectionist */ |
||
8 | protected $projectionist; |
||
9 | |||
10 | /** @var array */ |
||
11 | protected $config; |
||
12 | |||
13 | public function __construct(Projectionist $projectionist, array $config) |
||
19 | |||
20 | public function subscribe($events) |
||
24 | |||
25 | public function handle(string $eventName, $payload) |
||
26 | { |
||
27 | if (! $this->shouldBeStored($eventName)) { |
||
28 | return; |
||
29 | } |
||
30 | |||
31 | $this->storeEvent($payload[0]); |
||
32 | } |
||
33 | |||
34 | public function storeEvent(ShouldBeStored $event) |
||
38 | |||
39 | protected function shouldBeStored($event): bool |
||
47 | } |
||
48 |