1 | <?php |
||
10 | final class HandleStoredEventJob implements HandleDomainEventJob, ShouldQueue |
||
11 | { |
||
12 | use InteractsWithQueue, Queueable, SerializesModels; |
||
13 | |||
14 | public StoredEvent $storedEvent; |
||
|
|||
15 | |||
16 | public array $tags; |
||
17 | |||
18 | public function __construct(StoredEvent $storedEvent, array $tags) |
||
19 | { |
||
20 | $this->storedEvent = $storedEvent; |
||
21 | |||
22 | $this->tags = $tags; |
||
23 | } |
||
24 | |||
25 | public function handle(Projectionist $projectionist): void |
||
26 | { |
||
27 | $projectionist->handle($this->storedEvent); |
||
28 | } |
||
29 | |||
30 | public function tags(): array |
||
31 | { |
||
32 | return empty($this->tags) |
||
33 | ? [$this->storedEvent->event_class] |
||
34 | : $this->tags; |
||
35 | } |
||
36 | |||
37 | public static function createForEvent(StoredEvent $event, array $tags): HandleDomainEventJob |
||
38 | { |
||
39 | return new static($event, $tags); |
||
40 | } |
||
41 | } |
||
42 |