@@ 11-45 (lines=35) @@ | ||
8 | use Spatie\EventProjector\EventProjectionist; |
|
9 | use Spatie\EventProjector\Console\Concerns\ReplaysEvents; |
|
10 | ||
11 | class RebuildCommand extends Command |
|
12 | { |
|
13 | use ReplaysEvents, SelectsProjectors; |
|
14 | ||
15 | protected $signature = 'event-projector:rebuild {projector?*}'; |
|
16 | ||
17 | protected $description = 'Rebuild a projector'; |
|
18 | ||
19 | /** @var \Spatie\EventProjector\EventProjectionist */ |
|
20 | protected $eventProjectionist; |
|
21 | ||
22 | public function __construct(EventProjectionist $eventProjectionist) |
|
23 | { |
|
24 | parent::__construct(); |
|
25 | ||
26 | $this->eventProjectionist = $eventProjectionist; |
|
27 | } |
|
28 | ||
29 | public function handle() |
|
30 | { |
|
31 | $projectors = $this->selectsProjectors($this->argument('projector'), 'Are you sure to rebuild all projectors?'); |
|
32 | ||
33 | if (is_null($projectors)) { |
|
34 | $this->warn('No projectors rebuild!'); |
|
35 | ||
36 | return; |
|
37 | } |
|
38 | ||
39 | $projectors->each->reset(); |
|
40 | ||
41 | $this->replayEvents($projectors); |
|
42 | ||
43 | $this->comment('Projector(s) rebuild!'); |
|
44 | } |
|
45 | } |
|
46 |
@@ 13-48 (lines=36) @@ | ||
10 | use Spatie\EventProjector\Console\Concerns\ReplaysEvents; |
|
11 | use Spatie\EventProjector\Exceptions\InvalidEventHandler; |
|
12 | ||
13 | class ReplayCommand extends Command |
|
14 | { |
|
15 | use ReplaysEvents, SelectsProjectors; |
|
16 | ||
17 | protected $signature = 'event-projector:replay {projector?*}'; |
|
18 | ||
19 | protected $description = 'Replay stored events'; |
|
20 | ||
21 | /** @var \Spatie\EventProjector\EventProjectionist */ |
|
22 | protected $eventProjectionist; |
|
23 | ||
24 | /** @var string */ |
|
25 | protected $storedEventModelClass; |
|
26 | ||
27 | public function __construct(EventProjectionist $eventProjectionist, string $storedEventModelClass) |
|
28 | { |
|
29 | parent::__construct(); |
|
30 | ||
31 | $this->eventProjectionist = $eventProjectionist; |
|
32 | ||
33 | $this->storedEventModelClass = $storedEventModelClass; |
|
34 | } |
|
35 | ||
36 | public function handle() |
|
37 | { |
|
38 | $projectors = $this->selectsProjectors($this->argument('projector'), 'Are you sure you want to replay events to all projectors?'); |
|
39 | ||
40 | if (is_null($projectors)) { |
|
41 | $this->warn('No events replayed!'); |
|
42 | ||
43 | return; |
|
44 | } |
|
45 | ||
46 | $this->replayEvents($projectors); |
|
47 | } |
|
48 | } |
|
49 |
@@ 10-42 (lines=33) @@ | ||
7 | use Spatie\EventProjector\Console\Concerns\SelectsProjectors; |
|
8 | use Spatie\EventProjector\EventProjectionist; |
|
9 | ||
10 | class ResetCommand extends Command |
|
11 | { |
|
12 | use SelectsProjectors; |
|
13 | ||
14 | protected $signature = 'event-projector:reset {projector*}'; |
|
15 | ||
16 | protected $description = 'Reset a projector'; |
|
17 | ||
18 | /** @var \Spatie\EventProjector\EventProjectionist */ |
|
19 | protected $eventProjectionist; |
|
20 | ||
21 | public function __construct(EventProjectionist $eventProjectionist) |
|
22 | { |
|
23 | parent::__construct(); |
|
24 | ||
25 | $this->eventProjectionist = $eventProjectionist; |
|
26 | } |
|
27 | ||
28 | public function handle() |
|
29 | { |
|
30 | $projectors = $this->selectsProjectors($this->argument('projector'), 'Are you sure to reset all projectors?'); |
|
31 | ||
32 | if (is_null($projectors)) { |
|
33 | $this->warn('No projectors reset!'); |
|
34 | ||
35 | return; |
|
36 | } |
|
37 | ||
38 | $projectors->each->reset(); |
|
39 | ||
40 | $this->comment('Projector(s) reset!'); |
|
41 | } |
|
42 | } |
|
43 |