Skip to content

Commit 65878b1

Browse files
author
Tobias Wojtylak
committed
Use anonymous function for parsing steps
1 parent 2b3aa47 commit 65878b1

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

src/Context/FlowContext.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function getNextStep(): ?MultiStepInterface
3737
do {
3838
$nextStep = $this->flow->getStepAfter($currentStep);
3939
$currentStep = $nextStep;
40-
} while (null !== $nextStep && $nextStep->getStepRequiredChecker()->check() === false);
40+
} while (null !== $nextStep && false === $nextStep->getStepRequiredChecker()->check());
4141

4242
return $nextStep;
4343
}
@@ -48,7 +48,7 @@ public function getPreviousStep(): ?MultiStepInterface
4848
do {
4949
$previousStep = $this->flow->getStepBefore($currentStep);
5050
$currentStep = $previousStep;
51-
} while (null !== $previousStep && $previousStep->getStepRequiredChecker()->check() === false);
51+
} while (null !== $previousStep && false === $previousStep->getStepRequiredChecker()->check());
5252

5353
return $previousStep;
5454
}

src/DependencyInjection/MultiStepExtension.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,13 @@ private function parseFlows(array $flowsArray, ContainerBuilder $container): voi
4040
{
4141
$registryDefinition = $container->getDefinition('sd.multistep.flow_registry');
4242
foreach ($flowsArray as $id => $flowConfig) {
43-
$flowConfig['steps'] = array_map([$this, 'getStepOption'], $flowConfig['steps']);
43+
$flowConfig['steps'] = array_map(function (array $options): array {
44+
if (isset($options['stepRequiredChecker'])) {
45+
$options['stepRequiredChecker'] = new Reference($options['stepRequiredChecker']);
46+
}
47+
return $options;
48+
}, $flowConfig['steps']);
4449
$registryDefinition->addMethodCall('addByConfig', [$id, $flowConfig]);
4550
}
4651
}
47-
48-
/**
49-
* @param string[] $stepConfig
50-
*
51-
* @return string[]
52-
*/
53-
private function getStepOption(array $stepConfig): array
54-
{
55-
$options = $stepConfig;
56-
if (isset($options['stepRequiredChecker'])) {
57-
$options['stepRequiredChecker'] = new Reference($options['stepRequiredChecker']);
58-
}
59-
return $options;
60-
}
6152
}

0 commit comments

Comments
 (0)