Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
AddSharedResources | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
getSubscribedEvents | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
addSharedResources | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 |
1 | <?php |
2 | namespace Apie\Common\Events; |
3 | |
4 | use Apie\Core\BackgroundProcess\SequentialBackgroundProcess; |
5 | use Apie\Core\BoundedContext\BoundedContext; |
6 | use ReflectionClass; |
7 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
8 | |
9 | class AddSharedResources implements EventSubscriberInterface |
10 | { |
11 | public static function getSubscribedEvents(): array |
12 | { |
13 | return [RegisterBoundedContexts::class => 'addSharedResources']; |
14 | } |
15 | |
16 | public function addSharedResources(RegisterBoundedContexts $registerBoundedContexts): void |
17 | { |
18 | foreach ($registerBoundedContexts->hashmap as $boundedContext) { |
19 | /** @var BoundedContext $boundedContext */ |
20 | $lists = $boundedContext->findRelatedClasses()->toStringArray(); |
21 | if (in_array(SequentialBackgroundProcess::class, $lists)) { |
22 | // @phpstan-ignore property.readOnlyAssignOutOfClass |
23 | $boundedContext->resources[] = new ReflectionClass(SequentialBackgroundProcess::class); |
24 | } |
25 | } |
26 | } |
27 | } |