Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[WIP][Workflow] Changed initial_places to initial_marking, added property instead of type #30662

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions 21 UPGRADE-4.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@ Workflow
initial_places: [draft]
```

Yaml
----

* Using a mapping inside a multi-line string is deprecated and will throw a `ParseException` in 5.0.

Workflow
--------

Expand Down Expand Up @@ -183,19 +178,22 @@ Workflow
```yaml
framework:
workflows:
type: workflow
article:
marking_store:
type: multiple
arguments: states
lyrixx marked this conversation as resolved.
Show resolved Hide resolved
```

After:
```yaml
framework:
workflows:
type: workflow
article:
marking_store:
type: method

property: states
```

* `SingleStateMarkingStore` is deprecated. Use `MethodMarkingStore` instead.
Expand All @@ -206,16 +204,21 @@ Workflow
workflows:
article:
marking_store:
type: single
arguments: state
```

After:
```yaml
framework:
workflows:
type: state_machine
article:
marking_store:
type: method
arguments:
- true
property: state
```

Yaml
----

* Using a mapping inside a multi-line string is deprecated and will throw a `ParseException` in 5.0.
43 changes: 41 additions & 2 deletions 43 UPGRADE-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,47 @@ Workflow
* `ClassInstanceSupportStrategy` has been removed, use `InstanceOfSupportStrategy` instead.
* `MarkingStoreInterface::setMarking()` has a third argument: `array $context = []`.
* Removed support of `initial_place`. Use `initial_places` instead.
* `MultipleStateMarkingStore` has been removed.
* `SingleStateMarkingStore` has been removed.
* `MultipleStateMarkingStore` has been removed. Use `MethodMarkingStore` instead.

Before:
```yaml
framework:
workflows:
type: workflow
article:
marking_store:
type: multiple
arguments: states
```

After:
```yaml
framework:
workflows:
type: workflow
article:
marking_store:
property: states
```
* `SingleStateMarkingStore` has been removed. Use `MethodMarkingStore` instead.

Before:
```yaml
framework:
workflows:
article:
marking_store:
arguments: state
```

After:
```yaml
framework:
workflows:
article:
marking_store:
property: state
```

Yaml
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
$workflows = [];
}

if (1 === \count($workflows) && isset($workflows['workflows']) && array_keys($workflows['workflows']) !== range(0, \count($workflows) - 1) && !empty(array_diff(array_keys($workflows['workflows']), ['audit_trail', 'type', 'marking_store', 'supports', 'support_strategy', 'initial_places', 'places', 'transitions']))) {
if (1 === \count($workflows) && isset($workflows['workflows']) && array_keys($workflows['workflows']) !== range(0, \count($workflows) - 1) && !empty(array_diff(array_keys($workflows['workflows']), ['audit_trail', 'type', 'marking_store', 'supports', 'support_strategy', 'initial_marking', 'places', 'transitions']))) {
$workflows = $workflows['workflows'];
}

Expand All @@ -256,9 +256,17 @@ 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('initial_place')
->fixXmlConfig('transition')
->children()
->arrayNode('audit_trail')
Expand All @@ -272,9 +280,11 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
->fixXmlConfig('argument')
->children()
->enumNode('type')
->setDeprecated('The "%path%.%node%" configuration key has been deprecated in Symfony 4.3. Use "method" instead as it will be the only option in Symfony 5.0.')
->values(['multiple_state', 'single_state', 'method'])
->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]; })
Expand All @@ -283,6 +293,9 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
->prototype('scalar')
->end()
->end()
->scalarNode('property')
->defaultNull()
->end()
->scalarNode('service')
->cannotBeEmpty()
->end()
Expand All @@ -295,6 +308,10 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
->ifTrue(function ($v) { return !empty($v['arguments']) && isset($v['service']); })
->thenInvalid('"arguments" and "service" cannot be used together.')
->end()
->validate()
->ifTrue(function ($v) { return !empty($v['property']) && isset($v['service']); })
->thenInvalid('"property" and "service" cannot be used together.')
->end()
->end()
->arrayNode('supports')
->beforeNormalization()
Expand All @@ -313,10 +330,10 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
->cannotBeEmpty()
->end()
->scalarNode('initial_place')
->setDeprecated('The "%path%.%node%" configuration key has been deprecated in Symfony 4.3, use the "initial_places" configuration key instead.')
->setDeprecated('The "%path%.%node%" configuration key has been deprecated in Symfony 4.3, use the "initial_marking" configuration key instead.')
->defaultNull()
->end()
->arrayNode('initial_places')
->arrayNode('initial_marking')
->beforeNormalization()
->ifTrue(function ($v) { return !\is_array($v); })
->then(function ($v) { return [$v]; })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,14 +621,14 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $

// Create places
$places = array_column($workflow['places'], 'name');
$initialPlaces = $workflow['initial_places'] ?? $workflow['initial_place'] ?? [];
$initialMarking = $workflow['initial_marking'] ?? $workflow['initial_place'] ?? [];

// Create a Definition
$definitionDefinition = new Definition(Workflow\Definition::class);
$definitionDefinition->setPublic(false);
$definitionDefinition->addArgument($places);
$definitionDefinition->addArgument($transitions);
$definitionDefinition->addArgument($initialPlaces);
$definitionDefinition->addArgument($initialMarking);
$definitionDefinition->addArgument($metadataStoreDefinition);

// Create MarkingStore
Expand All @@ -637,6 +637,12 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
foreach ($workflow['marking_store']['arguments'] as $argument) {
$markingStoreDefinition->addArgument($argument);
}
if ('method' === $workflow['marking_store']['type']) {
$markingStoreDefinition->setArguments([
'state_machine' === $type, //single state
lyrixx marked this conversation as resolved.
Show resolved Hide resolved
$workflow['marking_store']['property'] ?? 'marking',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the default value in the Configuration (not the extension)

]);
}
} elseif (isset($workflow['marking_store']['service'])) {
$markingStoreDefinition = new Reference($workflow['marking_store']['service']);
}
Expand Down Expand Up @@ -676,7 +682,7 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
->addTransitions(array_map(function (Reference $ref) use ($container): Workflow\Transition {
return $container->get((string) $ref);
}, $transitions))
->setInitialPlace($initialPlaces)
->setInitialPlace($initialMarking)
->build()
;
$validator->validate($realDefinition, $name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@

<xsd:complexType name="workflow">
<xsd:sequence>
<xsd:element name="initial-place" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="initial-marking" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both element should be here to support the BC, no ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

<xsd:element name="marking-store" type="marking_store" minOccurs="0" maxOccurs="1" />
<xsd:element name="support" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="place" type="place" minOccurs="0" maxOccurs="unbounded" />
Expand All @@ -280,6 +280,7 @@
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="workflow_type" />
<xsd:attribute name="initial-place" type="xsd:string" />
<xsd:attribute name="initial-marking" type="xsd:string" />
<xsd:attribute name="support-strategy" type="xsd:string" />
<xsd:attribute name="enabled" type="xsd:boolean" />
</xsd:complexType>
Expand All @@ -295,12 +296,14 @@
</xsd:sequence>
<xsd:attribute name="type" type="marking_store_type" />
<xsd:attribute name="service" type="xsd:string" />
<xsd:attribute name="property" type="xsd:string" />
</xsd:complexType>

<xsd:simpleType name="marking_store_type">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="multiple_state" />
<xsd:enumeration value="single_state" />
<xsd:enumeration value="method" />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a kind of bug fix

</xsd:restriction>
</xsd:simpleType>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest;

$container->loadFromExtension('framework', [
'workflows' => [
'legacy' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'workflows' => [
'my_workflow' => [
'marking_store' => [
'type' => 'multiple_state',
'type' => 'method',
'service' => 'workflow_service',
],
'supports' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
'workflows' => [
'article' => [
'type' => 'workflow',
'marking_store' => [
'type' => 'multiple_state',
],
'supports' => [
FrameworkExtensionTest::class,
],
'initial_places' => ['draft'],
'initial_marking' => ['draft'],
'places' => [
'draft',
'wait_for_journalist',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
'workflows' => [
'article' => [
'type' => 'workflow',
'marking_store' => [
'type' => 'multiple_state',
],
'supports' => [
FrameworkExtensionTest::class,
],
'initial_places' => ['draft'],
'initial_marking' => ['draft'],
'places' => [
'draft',
'wait_for_journalist',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest;

$container->loadFromExtension('framework', [
'workflows' => [
'my_workflow' => [
'type' => 'workflow',
'marking_store' => [
'property' => 'states',
'service' => 'workflow_service',
],
'supports' => [
FrameworkExtensionTest::class,
],
'places' => [
'first',
'last',
],
'transitions' => [
'go' => [
'from' => [
'first',
],
'to' => [
'last',
],
],
],
],
],
]);
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
$container->loadFromExtension('framework', [
'workflows' => [
'my_workflow' => [
'marking_store' => [
'type' => 'multiple_state',
],
'type' => 'workflow',
'supports' => [
FrameworkExtensionTest::class,
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
<?php

use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest;

$container->loadFromExtension('framework', [
'workflows' => [
'my_workflow' => [
'marking_store' => [
'type' => 'multiple_state',
],
'type' => 'workflow',
'places' => [
'first',
'last',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
'workflows' => [
'article' => [
'type' => 'workflow',
'marking_store' => [
'type' => 'multiple_state',
],
'supports' => [
FrameworkExtensionTest::class,
],
'initial_places' => ['draft'],
'initial_marking' => ['draft'],
'places' => [
'draft',
'wait_for_journalist',
Expand Down Expand Up @@ -41,13 +38,10 @@
],
],
'pull_request' => [
'marking_store' => [
'type' => 'single_state',
],
'supports' => [
FrameworkExtensionTest::class,
],
'initial_places' => ['start'],
'initial_marking' => 'start',
'metadata' => [
'title' => 'workflow title',
],
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.