Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Workflow] Remove BC layers and deprecated codes #31824

Merged
merged 2 commits into from Jun 5, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -256,15 +256,6 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
->arrayNode('workflows')
->useAttributeAsKey('name')
->prototype('array')
->beforeNormalization()
->always(function ($v) {
if (isset($v['initial_place'])) {
$v['initial_marking'] = [$v['initial_place']];
}
return $v;
})
->end()
->fixXmlConfig('support')
->fixXmlConfig('place')
->fixXmlConfig('transition')
@@ -277,28 +268,9 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
->defaultValue('state_machine')
->end()
->arrayNode('marking_store')
->fixXmlConfig('argument')
->children()
->enumNode('type')
->values(['multiple_state', 'single_state', 'method'])
->validate()
->ifTrue(function ($v) { return 'method' !== $v; })
->then(function ($v) {
@trigger_error('Passing something else than "method" has been deprecated in Symfony 4.3.', E_USER_DEPRECATED);
return $v;
})
->end()
->end()
->arrayNode('arguments')
->setDeprecated('The "%path%.%node%" configuration key has been deprecated in Symfony 4.3. Use "property" instead.')
->beforeNormalization()
->ifString()
->then(function ($v) { return [$v]; })
->end()
->requiresAtLeastOneElement()
->prototype('scalar')
->end()
->values(['method'])
->end()
->scalarNode('property')
->defaultValue('marking')
@@ -307,14 +279,6 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
->cannotBeEmpty()
->end()
->end()
->validate()
->ifTrue(function ($v) { return isset($v['type']) && isset($v['service']); })
->thenInvalid('"type" and "service" cannot be used together.')
->end()
->validate()
->ifTrue(function ($v) { return !empty($v['arguments']) && isset($v['service']); })
->thenInvalid('"arguments" and "service" cannot be used together.')
->end()
->end()
->arrayNode('supports')
->beforeNormalization()
@@ -332,10 +296,6 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
->scalarNode('support_strategy')
->cannotBeEmpty()
->end()
->scalarNode('initial_place')
->setDeprecated('The "%path%.%node%" configuration key has been deprecated in Symfony 4.3, use the "initial_marking" configuration key instead.')
->defaultNull()
->end()
->arrayNode('initial_marking')
->beforeNormalization()
->ifTrue(function ($v) { return !\is_array($v); })
@@ -472,16 +432,6 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
})
->thenInvalid('"supports" or "support_strategy" should be configured.')
->end()
->validate()
->ifTrue(function ($v) {
return 'workflow' === $v['type'] && 'single_state' === ($v['marking_store']['type'] ?? false);
})
->then(function ($v) {
@trigger_error('Using a workflow with type=workflow and a marking_store=single_state is deprecated since Symfony 4.3. Use type=state_machine instead.', E_USER_DEPRECATED);
return $v;
})
->end()
->end()
->end()
->end()
@@ -627,7 +627,7 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
// Create places
$places = array_column($workflow['places'], 'name');
$initialMarking = $workflow['initial_marking'] ?? $workflow['initial_place'] ?? [];
$initialMarking = $workflow['initial_marking'] ?? [];
// Create a Definition
$definitionDefinition = new Definition(Workflow\Definition::class);
@@ -639,17 +639,11 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
// Create MarkingStore
if (isset($workflow['marking_store']['type'])) {
$markingStoreDefinition = new ChildDefinition('workflow.marking_store.'.$workflow['marking_store']['type']);
if ('method' === $workflow['marking_store']['type']) {
$markingStoreDefinition->setArguments([
'state_machine' === $type, //single state
$workflow['marking_store']['property'],
]);
} else {
foreach ($workflow['marking_store']['arguments'] as $argument) {
$markingStoreDefinition->addArgument($argument);
}
}
$markingStoreDefinition = new ChildDefinition('workflow.marking_store.method');
$markingStoreDefinition->setArguments([
'state_machine' === $type, //single state
$workflow['marking_store']['property'],
]);
} elseif (isset($workflow['marking_store']['service'])) {
$markingStoreDefinition = new Reference($workflow['marking_store']['service']);
}
@@ -668,29 +662,19 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
$container->registerAliasForArgument($workflowId, WorkflowInterface::class, $name.'.'.$type);
// Validate Workflow
$validator = null;
switch (true) {
case 'state_machine' === $workflow['type']:
$validator = new Workflow\Validator\StateMachineValidator();
break;
case 'single_state' === ($workflow['marking_store']['type'] ?? null):
$validator = new Workflow\Validator\WorkflowValidator(true);
break;
case 'multiple_state' === ($workflow['marking_store']['type'] ?? false):
$validator = new Workflow\Validator\WorkflowValidator(false);
break;
}
if ($validator) {
$realDefinition = (new Workflow\DefinitionBuilder($places))
->addTransitions(array_map(function (Reference $ref) use ($container): Workflow\Transition {
return $container->get((string) $ref);
}, $transitions))
->setInitialPlace($initialMarking)
->build()
;
$validator->validate($realDefinition, $name);
$realDefinition = (new Workflow\DefinitionBuilder($places))
->addTransitions(array_map(function (Reference $ref) use ($container): Workflow\Transition {
return $container->get((string) $ref);
}, $transitions))
->setInitialPlace($initialMarking)
->build()
;
if ('state_machine' === $workflow['type']) {
$validator = new Workflow\Validator\StateMachineValidator();
} else {
$validator = new Workflow\Validator\WorkflowValidator();
}
$validator->validate($realDefinition, $name);
// Add workflow to Registry
if ($workflow['supports']) {
@@ -20,8 +20,6 @@
<argument /> <!-- name -->
</service>

<service id="workflow.marking_store.multiple_state" class="Symfony\Component\Workflow\MarkingStore\MultipleStateMarkingStore" abstract="true" />
<service id="workflow.marking_store.single_state" class="Symfony\Component\Workflow\MarkingStore\SingleStateMarkingStore" abstract="true" />
<service id="workflow.marking_store.method" class="Symfony\Component\Workflow\MarkingStore\MethodMarkingStore" abstract="true" />

<service id="workflow.registry" class="Symfony\Component\Workflow\Registry" />

This file was deleted.

This file was deleted.

This file was deleted.

@@ -10,8 +10,8 @@
'places' => ['bar', 'baz'],
'transitions' => [
'bar_baz' => [
'from' => ['foo'],
'to' => ['bar'],
'from' => ['bar'],
'to' => ['baz'],
],
],
],
@@ -10,8 +10,8 @@
'places' => ['bar', 'baz'],
'transitions' => [
'bar_baz' => [
'from' => ['foo'],
'to' => ['bar'],
'from' => ['bar'],
'to' => ['baz'],
],
],
],

This file was deleted.

This file was deleted.

This file was deleted.

@@ -6,7 +6,7 @@
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">

<framework:config>
<framework:workflow enabled="true" name="foo" type="workflow" initial-marking="start">
<framework:workflow enabled="true" name="foo" type="workflow" initial-marking="bar">
<framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support>
<framework:place>bar</framework:place>
<framework:place>baz</framework:place>

This file was deleted.

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.