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