| Code Coverage | ||||||||||
| Lines | Functions and Methods | Classes and Traits | ||||||||
| Total |  | 55.56% | 5 / 9 |  | 50.00% | 1 / 2 | CRAP |  | 0.00% | 0 / 1 | 
| BackgroundProcessPersistListener |  | 55.56% | 5 / 9 |  | 50.00% | 1 / 2 | 3.79 |  | 0.00% | 0 / 1 | 
| getSubscribedEvents |  | 100.00% | 3 / 3 |  | 100.00% | 1 / 1 | 1 | |||
| onApieResourceUpdated |  | 33.33% | 2 / 6 |  | 0.00% | 0 / 1 | 3.19 | |||
| 1 | <?php | 
| 2 | namespace Apie\LaravelApie\Wrappers\Queue; | 
| 3 | |
| 4 | use Apie\ApieBundle\Messenger\RunSequentialProcessMessage; | 
| 5 | use Apie\Core\BackgroundProcess\SequentialBackgroundProcess; | 
| 6 | use Apie\Core\Datalayers\Events\EntityPersisted; | 
| 7 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; | 
| 8 | |
| 9 | class BackgroundProcessPersistListener implements EventSubscriberInterface | 
| 10 | { | 
| 11 | public static function getSubscribedEvents(): array | 
| 12 | { | 
| 13 | return [ | 
| 14 | EntityPersisted::class => 'onApieResourceUpdated' | 
| 15 | ]; | 
| 16 | } | 
| 17 | |
| 18 | public function onApieResourceUpdated(EntityPersisted $apieResourceCreated): void | 
| 19 | { | 
| 20 | $resource = $apieResourceCreated->entity; | 
| 21 | if ($resource instanceof SequentialBackgroundProcess) { | 
| 22 | RunBackgroundProcessJob::dispatch(new RunSequentialProcessMessage( | 
| 23 | $resource->getId(), | 
| 24 | $apieResourceCreated->boundedContextId | 
| 25 | )); | 
| 26 | } | 
| 27 | } | 
| 28 | } |