Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
Utils | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
__construct | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
runBackgroundProcess | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | namespace Apie\Core\BackgroundProcess; |
3 | |
4 | use Apie\Core\BoundedContext\BoundedContextId; |
5 | use Apie\Core\ContextBuilders\ContextBuilderFactory; |
6 | use Apie\Core\ContextConstants; |
7 | use Apie\Core\Datalayers\ApieDatalayer; |
8 | |
9 | final class Utils |
10 | { |
11 | /** |
12 | * @codeCoverageIgnore |
13 | */ |
14 | private function __construct() |
15 | { |
16 | } |
17 | |
18 | public static function runBackgroundProcess( |
19 | SequentialBackgroundProcessIdentifier $id, |
20 | ?BoundedContextId $boundedContextId, |
21 | ApieDatalayer $apieDatalayer, |
22 | ContextBuilderFactory $contextBuilderFactory |
23 | ): void { |
24 | $process = $apieDatalayer->find($id, $boundedContextId); |
25 | if ($process->getStatus() !== BackgroundProcessStatus::Active) { |
26 | return; |
27 | } |
28 | $context = []; |
29 | if ($boundedContextId) { |
30 | $context[ContextConstants::BOUNDED_CONTEXT_ID] = $boundedContextId->toNative(); |
31 | $context[BoundedContextId::class] = $boundedContextId; |
32 | } |
33 | |
34 | $apieContext = $contextBuilderFactory->createGeneralContext($context); |
35 | $process->runStep($apieContext); |
36 | $apieDatalayer->persistExisting($process, $boundedContextId); |
37 | } |
38 | } |