| Conditions | 1 |
| Paths | 1 |
| Total Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | public function handle(Projectionist $projectionist, Filesystem $files): void |
||
| 18 | { |
||
| 19 | $this->info('Caching registered event handlers...'); |
||
| 20 | |||
| 21 | $projectionist->getProjectors() |
||
| 22 | ->merge($projectionist->getReactors()) |
||
| 23 | ->map(function (EventHandler $eventHandler) { |
||
| 24 | return get_class($eventHandler); |
||
| 25 | }) |
||
| 26 | ->pipe(function (Collection $eventHandlerClasses) use ($files) { |
||
| 27 | $cachePath = config('event-projector.cache_path'); |
||
| 28 | |||
| 29 | $files->makeDirectory($cachePath, 0755, true, true); |
||
| 30 | |||
| 31 | $files->put( |
||
| 32 | $cachePath.'/event-handlers.php', |
||
| 33 | '<?php return '.var_export($eventHandlerClasses->toArray(), true).';' |
||
| 34 | ); |
||
| 35 | }); |
||
| 36 | |||
| 37 | $this->info('All done!'); |
||
| 38 | } |
||
| 39 | } |
||
| 40 |