Skip to content

Commit 2438820

Browse files
committed
[Workflow] streamline XML schema definition
1 parent a783412 commit 2438820

File tree

8 files changed

+304
-102
lines changed

8 files changed

+304
-102
lines changed

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

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<xsd:element name="config" type="config" />
99

1010
<xsd:complexType name="config">
11-
<xsd:all>
11+
<xsd:choice maxOccurs="unbounded">
1212
<xsd:element name="assets" type="assets" minOccurs="0" maxOccurs="1" />
1313
<xsd:element name="form" type="form" minOccurs="0" maxOccurs="1" />
1414
<xsd:element name="csrf-protection" type="csrf_protection" minOccurs="0" maxOccurs="1" />
@@ -26,8 +26,8 @@
2626
<xsd:element name="serializer" type="serializer" minOccurs="0" maxOccurs="1" />
2727
<xsd:element name="property-info" type="property_info" minOccurs="0" maxOccurs="1" />
2828
<xsd:element name="cache" type="cache" minOccurs="0" maxOccurs="1" />
29-
<xsd:element name="workflows" type="workflows" minOccurs="0" maxOccurs="1" />
30-
</xsd:all>
29+
<xsd:element name="workflow" type="workflow" minOccurs="0" maxOccurs="unbounded" />
30+
</xsd:choice>
3131

3232
<xsd:attribute name="http-method-override" type="xsd:boolean" />
3333
<xsd:attribute name="trusted-proxies" type="xsd:string" />
@@ -228,41 +228,44 @@
228228
<xsd:attribute name="clearer" type="xsd:string" />
229229
</xsd:complexType>
230230

231-
<xsd:complexType name="workflows">
232-
<xsd:choice minOccurs="0" maxOccurs="unbounded">
233-
<xsd:element name="workflow" type="workflow" />
234-
</xsd:choice>
235-
</xsd:complexType>
236-
237231
<xsd:complexType name="workflow">
238232
<xsd:sequence>
239233
<xsd:element name="marking-store" type="marking_store" />
240-
<xsd:element name="supports" type="xsd:string" minOccurs="1" maxOccurs="unbounded" />
241-
<xsd:element name="places" type="xsd:string" minOccurs="1" maxOccurs="unbounded" />
242-
<xsd:element name="transitions" type="transitions" />
234+
<xsd:element name="support" type="xsd:string" minOccurs="1" maxOccurs="unbounded" />
235+
<xsd:element name="place" type="xsd:string" minOccurs="1" maxOccurs="unbounded" />
236+
<xsd:element name="transition" type="transition" minOccurs="1" maxOccurs="unbounded" />
243237
</xsd:sequence>
244-
<xsd:attribute name="name" type="xsd:string" />
238+
<xsd:attribute name="name" type="xsd:string" use="required" />
239+
<xsd:attribute name="type" type="workflow_type" use="required" />
245240
</xsd:complexType>
246241

247242
<xsd:complexType name="marking_store">
248243
<xsd:sequence>
249-
<xsd:element name="type" type="xsd:string" minOccurs="0" maxOccurs="1" />
250-
<xsd:element name="arguments" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
251-
<xsd:element name="service" type="xsd:string" minOccurs="0" maxOccurs="1" />
244+
<xsd:element name="argument" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
252245
</xsd:sequence>
246+
<xsd:attribute name="type" type="marking_store_type" />
247+
<xsd:attribute name="service" type="xsd:string" />
253248
</xsd:complexType>
254249

255-
<xsd:complexType name="transitions">
256-
<xsd:sequence>
257-
<xsd:element name="transition" type="transition" />
258-
</xsd:sequence>
259-
</xsd:complexType>
250+
<xsd:simpleType name="marking_store_type">
251+
<xsd:restriction base="xsd:string">
252+
<xsd:enumeration value="multiple_state" />
253+
<xsd:enumeration value="single_state" />
254+
</xsd:restriction>
255+
</xsd:simpleType>
260256

261257
<xsd:complexType name="transition">
262258
<xsd:sequence>
263259
<xsd:element name="from" type="xsd:string" minOccurs="1" maxOccurs="unbounded" />
264260
<xsd:element name="to" type="xsd:string" minOccurs="1" maxOccurs="unbounded" />
265261
</xsd:sequence>
266-
<xsd:attribute name="name" type="xsd:string" />
262+
<xsd:attribute name="name" type="xsd:string" use="required" />
267263
</xsd:complexType>
264+
265+
<xsd:simpleType name="workflow_type">
266+
<xsd:restriction base="xsd:string">
267+
<xsd:enumeration value="state_machine" />
268+
<xsd:enumeration value="workflow" />
269+
</xsd:restriction>
270+
</xsd:simpleType>
268271
</xsd:schema>

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow.php

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?php
2+
3+
use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest;
4+
5+
$container->loadFromExtension('framework', array(
6+
'workflows' => array(
7+
'article' => array(
8+
'type' => 'workflow',
9+
'marking_store' => array(
10+
'type' => 'multiple_state',
11+
),
12+
'supports' => array(
13+
FrameworkExtensionTest::class,
14+
),
15+
'places' => array(
16+
'draft',
17+
'wait_for_journalist',
18+
'approved_by_journalist',
19+
'wait_for_spellchecker',
20+
'approved_by_spellchecker',
21+
'published',
22+
),
23+
'transitions' => array(
24+
'request_review' => array(
25+
'from' => 'draft',
26+
'to' => array('wait_for_journalist', 'wait_for_spellchecker'),
27+
),
28+
'journalist_approval' => array(
29+
'from' => 'wait_for_journalist',
30+
'to' => 'approved_by_journalist',
31+
),
32+
'spellchecker_approval' => array(
33+
'from' => 'wait_for_spellchecker',
34+
'to' => 'approved_by_spellchecker',
35+
),
36+
'publish' => array(
37+
'from' => array('approved_by_journalist', 'approved_by_spellchecker'),
38+
'to' => 'published',
39+
),
40+
),
41+
),
42+
'pull_request' => array(
43+
'type' => 'state_machine',
44+
'marking_store' => array(
45+
'type' => 'single_state',
46+
),
47+
'supports' => array(
48+
FrameworkExtensionTest::class,
49+
),
50+
'places' => array(
51+
'start',
52+
'coding',
53+
'travis',
54+
'review',
55+
'merged',
56+
'closed',
57+
),
58+
'transitions' => array(
59+
'submit' => array(
60+
'from' => 'start',
61+
'to' => 'travis',
62+
),
63+
'update' => array(
64+
'from' => array('coding', 'travis', 'review'),
65+
'to' => 'travis',
66+
),
67+
'wait_for_review' => array(
68+
'from' => 'travis',
69+
'to' => 'review',
70+
),
71+
'request_change' => array(
72+
'from' => 'review',
73+
'to' => 'coding',
74+
),
75+
'accept' => array(
76+
'from' => 'review',
77+
'to' => 'merged',
78+
),
79+
'reject' => array(
80+
'from' => 'review',
81+
'to' => 'closed',
82+
),
83+
'reopen' => array(
84+
'from' => 'closed',
85+
'to' => 'review',
86+
),
87+
),
88+
),
89+
),
90+
));

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow.xml

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?xml version="1.0" ?>
2+
3+
<container xmlns="http://symfony.com/schema/dic/services"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:framework="http://symfony.com/schema/dic/symfony"
6+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
7+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
8+
9+
<framework:config>
10+
<framework:workflow name="article" type="workflow">
11+
<framework:marking-store type="multiple_state">
12+
<framework:argument>a</framework:argument>
13+
<framework:argument>a</framework:argument>
14+
</framework:marking-store>
15+
<framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support>
16+
<framework:place>draft</framework:place>
17+
<framework:place>wait_for_journalist</framework:place>
18+
<framework:place>approved_by_journalist</framework:place>
19+
<framework:place>wait_for_spellchecker</framework:place>
20+
<framework:place>approved_by_spellchecker</framework:place>
21+
<framework:place>published</framework:place>
22+
<framework:transition name="request_review">
23+
<framework:from>draft</framework:from>
24+
<framework:to>wait_for_journalist</framework:to>
25+
<framework:to>wait_for_spellchecker</framework:to>
26+
</framework:transition>
27+
<framework:transition name="journalist_approval">
28+
<framework:from>wait_for_journalist</framework:from>
29+
<framework:to>approved_by_journalist</framework:to>
30+
</framework:transition>
31+
<framework:transition name="spellchecker_approval">
32+
<framework:from>wait_for_spellcheker</framework:from>
33+
<framework:to>approved_by_spellchker</framework:to>
34+
</framework:transition>
35+
<framework:transition name="publish">
36+
<framework:from>approved_by_journalist</framework:from>
37+
<framework:from>approved_by_spellchker</framework:from>
38+
<framework:to>published</framework:to>
39+
</framework:transition>
40+
</framework:workflow>
41+
42+
<framework:workflow name="pull_request" type="state_machine">
43+
<framework:marking-store type="single_state"/>
44+
<framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support>
45+
<framework:place>start</framework:place>
46+
<framework:place>coding</framework:place>
47+
<framework:place>travis</framework:place>
48+
<framework:place>review</framework:place>
49+
<framework:place>merged</framework:place>
50+
<framework:place>closed</framework:place>
51+
<framework:transition name="submit">
52+
<framework:from>start</framework:from>
53+
<framework:to>travis</framework:to>
54+
</framework:transition>
55+
<framework:transition name="update">
56+
<framework:from>coding</framework:from>
57+
<framework:from>travis</framework:from>
58+
<framework:from>review</framework:from>
59+
<framework:to>travis</framework:to>
60+
</framework:transition>
61+
<framework:transition name="wait_for_review">
62+
<framework:from>travis</framework:from>
63+
<framework:to>review</framework:to>
64+
</framework:transition>
65+
<framework:transition name="request_change">
66+
<framework:from>review</framework:from>
67+
<framework:to>coding</framework:to>
68+
</framework:transition>
69+
<framework:transition name="accept">
70+
<framework:from>review</framework:from>
71+
<framework:to>merged</framework:to>
72+
</framework:transition>
73+
<framework:transition name="reject">
74+
<framework:from>review</framework:from>
75+
<framework:to>closed</framework:to>
76+
</framework:transition>
77+
<framework:transition name="reopen">
78+
<framework:from>closed</framework:from>
79+
<framework:to>review</framework:to>
80+
</framework:transition>
81+
</framework:workflow>
82+
</framework:config>
83+
</container>

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)