Skip to content

Commit 94a7e7e

Browse files
committed
[Workflow] streamline XML schema definition
1 parent 6381caa commit 94a7e7e

File tree

8 files changed

+310
-102
lines changed

8 files changed

+310
-102
lines changed

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

+25-22
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,42 +228,45 @@
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" />
245240
<xsd:attribute name="initial-place" type="xsd:string" />
246241
</xsd:complexType>
247242

248243
<xsd:complexType name="marking_store">
249244
<xsd:sequence>
250-
<xsd:element name="type" type="xsd:string" minOccurs="0" maxOccurs="1" />
251-
<xsd:element name="arguments" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
252-
<xsd:element name="service" type="xsd:string" minOccurs="0" maxOccurs="1" />
245+
<xsd:element name="argument" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
253246
</xsd:sequence>
247+
<xsd:attribute name="type" type="marking_store_type" />
248+
<xsd:attribute name="service" type="xsd:string" />
254249
</xsd:complexType>
255250

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

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

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

-30
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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+
'initial_place' => 'draft',
16+
'places' => array(
17+
'draft',
18+
'wait_for_journalist',
19+
'approved_by_journalist',
20+
'wait_for_spellchecker',
21+
'approved_by_spellchecker',
22+
'published',
23+
),
24+
'transitions' => array(
25+
'request_review' => array(
26+
'from' => 'draft',
27+
'to' => array('wait_for_journalist', 'wait_for_spellchecker'),
28+
),
29+
'journalist_approval' => array(
30+
'from' => 'wait_for_journalist',
31+
'to' => 'approved_by_journalist',
32+
),
33+
'spellchecker_approval' => array(
34+
'from' => 'wait_for_spellchecker',
35+
'to' => 'approved_by_spellchecker',
36+
),
37+
'publish' => array(
38+
'from' => array('approved_by_journalist', 'approved_by_spellchecker'),
39+
'to' => 'published',
40+
),
41+
),
42+
),
43+
'pull_request' => array(
44+
'type' => 'state_machine',
45+
'marking_store' => array(
46+
'type' => 'single_state',
47+
),
48+
'supports' => array(
49+
FrameworkExtensionTest::class,
50+
),
51+
'initial_place' => 'start',
52+
'places' => array(
53+
'start',
54+
'coding',
55+
'travis',
56+
'review',
57+
'merged',
58+
'closed',
59+
),
60+
'transitions' => array(
61+
'submit' => array(
62+
'from' => 'start',
63+
'to' => 'travis',
64+
),
65+
'update' => array(
66+
'from' => array('coding', 'travis', 'review'),
67+
'to' => 'travis',
68+
),
69+
'wait_for_review' => array(
70+
'from' => 'travis',
71+
'to' => 'review',
72+
),
73+
'request_change' => array(
74+
'from' => 'review',
75+
'to' => 'coding',
76+
),
77+
'accept' => array(
78+
'from' => 'review',
79+
'to' => 'merged',
80+
),
81+
'reject' => array(
82+
'from' => 'review',
83+
'to' => 'closed',
84+
),
85+
'reopen' => array(
86+
'from' => 'closed',
87+
'to' => 'review',
88+
),
89+
),
90+
),
91+
),
92+
));

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

-29
This file was deleted.
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" initial-place="draft">
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" initial-place="start">
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

-16
This file was deleted.

0 commit comments

Comments
 (0)