Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit73708a6

Browse files
HeahDudelyrixx
authored andcommitted
[Workflow] Changed initial_places to initial_marking, added property instead of type
1 parent5fe3701 commit73708a6

File tree

38 files changed

+214
-98
lines changed

38 files changed

+214
-98
lines changed

‎UPGRADE-4.3.md‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,6 @@ Workflow
166166
initial_places: [draft]
167167
```
168168

169-
Yaml
170-
----
171-
172-
* Using a mapping inside a multi-line string is deprecated and will throw a `ParseException` in 5.0.
173-
174169
Workflow
175170
--------
176171

@@ -202,19 +197,22 @@ Workflow
202197
```yaml
203198
framework:
204199
workflows:
200+
type: workflow
205201
article:
206202
marking_store:
207203
type: multiple
204+
arguments: states
208205
```
209206

210207
After:
211208
```yaml
212209
framework:
213210
workflows:
211+
type: workflow
214212
article:
215213
marking_store:
216214
type: method
217-
215+
property: states
218216
```
219217

220218
* `SingleStateMarkingStore` is deprecated. Use `MethodMarkingStore` instead.
@@ -225,16 +223,21 @@ Workflow
225223
workflows:
226224
article:
227225
marking_store:
228-
type: single
226+
arguments: state
229227
```
230228

231229
After:
232230
```yaml
233231
framework:
234232
workflows:
233+
type: state_machine
235234
article:
236235
marking_store:
237236
type: method
238-
arguments:
239-
- true
237+
property: state
240238
```
239+
240+
Yaml
241+
----
242+
243+
* Using a mapping inside a multi-line string is deprecated and will throw a `ParseException` in 5.0.

‎UPGRADE-5.0.md‎

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,47 @@ Workflow
388388
* `ClassInstanceSupportStrategy` has been removed, use `InstanceOfSupportStrategy` instead.
389389
* `MarkingStoreInterface::setMarking()` has a third argument: `array $context = []`.
390390
* Removed support of `initial_place`. Use `initial_places` instead.
391-
* `MultipleStateMarkingStore` has been removed.
392-
* `SingleStateMarkingStore` has been removed.
391+
* `MultipleStateMarkingStore` has been removed. Use `MethodMarkingStore` instead.
392+
393+
Before:
394+
```yaml
395+
framework:
396+
workflows:
397+
type: workflow
398+
article:
399+
marking_store:
400+
type: multiple
401+
arguments: states
402+
```
403+
404+
After:
405+
```yaml
406+
framework:
407+
workflows:
408+
type: workflow
409+
article:
410+
marking_store:
411+
property: states
412+
```
413+
* `SingleStateMarkingStore` has been removed. Use `MethodMarkingStore` instead.
414+
415+
Before:
416+
```yaml
417+
framework:
418+
workflows:
419+
article:
420+
marking_store:
421+
arguments: state
422+
```
423+
424+
After:
425+
```yaml
426+
framework:
427+
workflows:
428+
article:
429+
marking_store:
430+
property: state
431+
```
393432

394433
Yaml
395434
----

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
233233
$workflows = [];
234234
}
235235

236-
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']))) {
236+
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']))) {
237237
$workflows =$workflows['workflows'];
238238
}
239239

@@ -258,9 +258,17 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
258258
->arrayNode('workflows')
259259
->useAttributeAsKey('name')
260260
->prototype('array')
261+
->beforeNormalization()
262+
->always(function ($v) {
263+
if (isset($v['initial_place'])) {
264+
$v['initial_marking'] = [$v['initial_place']];
265+
}
266+
267+
return$v;
268+
})
269+
->end()
261270
->fixXmlConfig('support')
262271
->fixXmlConfig('place')
263-
->fixXmlConfig('initial_place')
264272
->fixXmlConfig('transition')
265273
->children()
266274
->arrayNode('audit_trail')
@@ -274,9 +282,11 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
274282
->fixXmlConfig('argument')
275283
->children()
276284
->enumNode('type')
285+
->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.')
277286
->values(['multiple_state','single_state','method'])
278287
->end()
279288
->arrayNode('arguments')
289+
->setDeprecated('The "%path%.%node%" configuration key has been deprecated in Symfony 4.3. Use "property" instead.')
280290
->beforeNormalization()
281291
->ifString()
282292
->then(function ($v) {return [$v]; })
@@ -285,6 +295,9 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
285295
->prototype('scalar')
286296
->end()
287297
->end()
298+
->scalarNode('property')
299+
->defaultNull()
300+
->end()
288301
->scalarNode('service')
289302
->cannotBeEmpty()
290303
->end()
@@ -297,6 +310,10 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
297310
->ifTrue(function ($v) {return !empty($v['arguments']) &&isset($v['service']); })
298311
->thenInvalid('"arguments" and "service" cannot be used together.')
299312
->end()
313+
->validate()
314+
->ifTrue(function ($v) {return !empty($v['property']) &&isset($v['service']); })
315+
->thenInvalid('"property" and "service" cannot be used together.')
316+
->end()
300317
->end()
301318
->arrayNode('supports')
302319
->beforeNormalization()
@@ -315,10 +332,10 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
315332
->cannotBeEmpty()
316333
->end()
317334
->scalarNode('initial_place')
318-
->setDeprecated('The "%path%.%node%" configuration key has been deprecated in Symfony 4.3, use the "initial_places" configuration key instead.')
335+
->setDeprecated('The "%path%.%node%" configuration key has been deprecated in Symfony 4.3, use the "initial_marking" configuration key instead.')
319336
->defaultNull()
320337
->end()
321-
->arrayNode('initial_places')
338+
->arrayNode('initial_marking')
322339
->beforeNormalization()
323340
->ifTrue(function ($v) {return !\is_array($v); })
324341
->then(function ($v) {return [$v]; })

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,14 +631,14 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
631631

632632
// Create places
633633
$places =array_column($workflow['places'],'name');
634-
$initialPlaces =$workflow['initial_places'] ??$workflow['initial_place'] ?? [];
634+
$initialMarking =$workflow['initial_marking'] ??$workflow['initial_place'] ?? [];
635635

636636
// Create a Definition
637637
$definitionDefinition =newDefinition(Workflow\Definition::class);
638638
$definitionDefinition->setPublic(false);
639639
$definitionDefinition->addArgument($places);
640640
$definitionDefinition->addArgument($transitions);
641-
$definitionDefinition->addArgument($initialPlaces);
641+
$definitionDefinition->addArgument($initialMarking);
642642
$definitionDefinition->addArgument($metadataStoreDefinition);
643643

644644
// Create MarkingStore
@@ -647,6 +647,12 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
647647
foreach ($workflow['marking_store']['arguments']as$argument) {
648648
$markingStoreDefinition->addArgument($argument);
649649
}
650+
if ('method' ===$workflow['marking_store']['type']) {
651+
$markingStoreDefinition->setArguments([
652+
'state_machine' ===$type,//single state
653+
$workflow['marking_store']['property'] ??'marking',
654+
]);
655+
}
650656
}elseif (isset($workflow['marking_store']['service'])) {
651657
$markingStoreDefinition =newReference($workflow['marking_store']['service']);
652658
}
@@ -686,7 +692,7 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
686692
->addTransitions(array_map(function (Reference$ref)use ($container):Workflow\Transition {
687693
return$container->get((string)$ref);
688694
},$transitions))
689-
->setInitialPlace($initialPlaces)
695+
->setInitialPlace($initialMarking)
690696
->build()
691697
;
692698
$validator->validate($realDefinition,$name);

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@
279279

280280
<xsd:complexTypename="workflow">
281281
<xsd:sequence>
282-
<xsd:elementname="initial-place"type="xsd:string"minOccurs="0"maxOccurs="unbounded" />
282+
<xsd:elementname="initial-marking"type="xsd:string"minOccurs="0"maxOccurs="unbounded" />
283283
<xsd:elementname="marking-store"type="marking_store"minOccurs="0"maxOccurs="1" />
284284
<xsd:elementname="support"type="xsd:string"minOccurs="0"maxOccurs="unbounded" />
285285
<xsd:elementname="place"type="place"minOccurs="0"maxOccurs="unbounded" />
@@ -289,6 +289,7 @@
289289
<xsd:attributename="name"type="xsd:string" />
290290
<xsd:attributename="type"type="workflow_type" />
291291
<xsd:attributename="initial-place"type="xsd:string" />
292+
<xsd:attributename="initial-marking"type="xsd:string" />
292293
<xsd:attributename="support-strategy"type="xsd:string" />
293294
<xsd:attributename="enabled"type="xsd:boolean" />
294295
</xsd:complexType>
@@ -304,12 +305,14 @@
304305
</xsd:sequence>
305306
<xsd:attributename="type"type="marking_store_type" />
306307
<xsd:attributename="service"type="xsd:string" />
308+
<xsd:attributename="property"type="xsd:string" />
307309
</xsd:complexType>
308310

309311
<xsd:simpleTypename="marking_store_type">
310312
<xsd:restrictionbase="xsd:string">
311313
<xsd:enumerationvalue="multiple_state" />
312314
<xsd:enumerationvalue="single_state" />
315+
<xsd:enumerationvalue="method" />
313316
</xsd:restriction>
314317
</xsd:simpleType>
315318

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow-legacy.php‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
useSymfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest;
4-
53
$container->loadFromExtension('framework', [
64
'workflows' => [
75
'legacy' => [
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
'workflows' => [
77
'my_workflow' => [
88
'marking_store' => [
9-
'type' =>'multiple_state',
9+
'type' =>'method',
1010
'service' =>'workflow_service',
1111
],
1212
'supports' => [

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66
'workflows' => [
77
'article' => [
88
'type' =>'workflow',
9-
'marking_store' => [
10-
'type' =>'multiple_state',
11-
],
129
'supports' => [
1310
FrameworkExtensionTest::class,
1411
],
15-
'initial_places' => ['draft'],
12+
'initial_marking' => ['draft'],
1613
'places' => [
1714
'draft',
1815
'wait_for_journalist',

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_multiple_transitions_with_same_name.php‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66
'workflows' => [
77
'article' => [
88
'type' =>'workflow',
9-
'marking_store' => [
10-
'type' =>'multiple_state',
11-
],
129
'supports' => [
1310
FrameworkExtensionTest::class,
1411
],
15-
'initial_places' => ['draft'],
12+
'initial_marking' => ['draft'],
1613
'places' => [
1714
'draft',
1815
'wait_for_journalist',

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp