|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Darkilliant\ProcessBundle\Runner; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
|
6
|
|
|
use Darkilliant\ProcessBundle\Configuration\ConfigurationProcess; |
|
7
|
|
|
use Darkilliant\ProcessBundle\Configuration\ConfigurationStep; |
|
8
|
|
|
use Darkilliant\ProcessBundle\Logger\InMemoryLogger; |
|
9
|
|
|
use Darkilliant\ProcessBundle\State\ProcessState; |
|
10
|
|
|
use Darkilliant\ProcessBundle\Step\IterableStepInterface; |
|
11
|
|
|
use Darkilliant\ProcessBundle\Step\LaunchProcessStep; |
|
12
|
|
|
use Darkilliant\ProcessBundle\Step\StepInterface; |
|
13
|
|
|
|
|
14
|
|
|
class StepDescripterRunner extends StepRunner |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* @param string $processName |
|
18
|
|
|
* |
|
19
|
|
|
* @throws \Exception |
|
20
|
|
|
* |
|
21
|
|
|
* @return ConfigurationProcess |
|
22
|
|
|
*/ |
|
23
|
3 |
|
public function buildConfigurationProcess(string $processName, string $logger = null): ConfigurationProcess |
|
24
|
|
|
{ |
|
25
|
3 |
|
return parent::buildConfigurationProcess($processName, InMemoryLogger::class); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
1 |
|
protected function configureOptions(StepInterface $service, ConfigurationStep $step, ProcessState $processState): ProcessState |
|
29
|
|
|
{ |
|
30
|
1 |
|
return $processState->setOptions( |
|
31
|
1 |
|
$service->configureOptionResolver(new OptionsResolver())->resolve($step->getOptions()) |
|
32
|
|
|
); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
1 |
|
protected function runStep(ProcessState $processState, ConfigurationStep $step): int |
|
36
|
|
|
{ |
|
37
|
1 |
|
if (LaunchProcessStep::class === $step->getService()) { |
|
38
|
1 |
|
parent::runStep($processState, $step); |
|
39
|
|
|
|
|
40
|
1 |
|
return ProcessState::RESULT_OK; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @var ConfigurationStep |
|
45
|
|
|
*/ |
|
46
|
1 |
|
$service = $this->registry->resolveService($step->getService()); |
|
47
|
|
|
|
|
48
|
1 |
|
$this->configureOptions($service, $step, $processState); |
|
49
|
1 |
|
$service->describe($processState); |
|
50
|
|
|
|
|
51
|
1 |
|
if ($service instanceof IterableStepInterface) { |
|
52
|
1 |
|
$this->runSteps($processState, $step->getChildren()); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
1 |
|
return ProcessState::RESULT_OK; |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|