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

Added XML support for Workflow configuration #20458

Merged
merged 2 commits into from Nov 16, 2016
Merged

Conversation

wouterj
Copy link
Member

@wouterj wouterj commented Nov 9, 2016

Q A
Branch? master
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR symfony/symfony-docs#6871

@lyrixx
Copy link
Member

lyrixx commented Nov 9, 2016

@wouterj I never used the XML config, but previous tests were OK. So I'm not 100% sure about this PR. Did you test it ? Should we add more tests ?

@wouterj
Copy link
Member Author

wouterj commented Nov 9, 2016

@lyrixx I couldn't find any tests for workflow config (did a very quick search though). Prototyped arrays are represented by multiple occurences of the same element in XML. For example:

workflows:
    blogpost: ...
    pull_request: ...
<workflow name="blogpost">...</workflow>
<workflow name="pull_request">...</workflow>

As you can see, this difference in format means the Config processor has to be aware of singular and plural versions of all prototyped config names (workflows vs workflow). This is done by adding these ->fixXmlConfig() calls.

@javiereguiluz javiereguiluz added this to the 3.2 milestone Nov 10, 2016
@lyrixx
Copy link
Member

lyrixx commented Nov 10, 2016

@wouterj Could you rebase please?

@xabbuh
Copy link
Member

xabbuh commented Nov 10, 2016

👍 after rebasing

@xabbuh
Copy link
Member

xabbuh commented Nov 11, 2016

I rebased this PR and also updated the XML schema definition. The changes made by @wouterj were technically not needed with the definition before, but having it this way is more inline with how we define XML configs elsewhere.

ping @symfony/deciders

@xabbuh
Copy link
Member

xabbuh commented Nov 11, 2016

type and service are now attributes instead of elements as suggested by @stof in #20482 (comment).

@@ -235,12 +235,16 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
->arrayNode('workflows')
Copy link
Member

Choose a reason for hiding this comment

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

missing ->fixXmlConfig('workflow') on the root node IMO, as having a workflows node for the list of workflows does not match the way things are done (and btw, it will cause issues when you define 1 vs several workflows in XML currently AFAIK. Please test this case)

Copy link
Member

Choose a reason for hiding this comment

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

The issue is the xsd:all node which we use as the top-level node of the config node. Afaik this doesn't allow us to specifiy several workflow nodes. That's why the workflow nodes are wrapped inside the workflows node and calling fixXmlConfig() isn't necessary for the workflow config node.

Copy link
Member

Choose a reason for hiding this comment

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

then please write a test which defined multiple workflows in the same file too. I'm quite sure that the current setup is broken (it works by chance here when there is a single workflow, due to the way XML gets parsed, which is different when there is a single child with a given tag vs multiple childs, which is precisely why we fix the XML config for prototyped nodes)

Copy link
Member

Choose a reason for hiding this comment

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

You're right. Tests added and XSD updated accordingly.

</xsd:sequence>
<xsd:attribute name="type" type="xsd:string" use="optional" />
<xsd:attribute name="service" type="xsd:string" use="optional" />
Copy link
Member

Choose a reason for hiding this comment

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

use="optional" is the default in XSD, and we always omit it.

Copy link
Member

Choose a reason for hiding this comment

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

You're right. I reverted this change and made the name attributes of the workflow and transition required instead.

@xabbuh xabbuh force-pushed the patch-12 branch 2 times, most recently from 1a61ab0 to 4dd1622 Compare November 11, 2016 11:53
<framework:place>last</framework:place>
<framework:transition name="foo">
<framework:from>a</framework:from>
<framework:to>a</framework:to>
Copy link
Member

Choose a reason for hiding this comment

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

As you have 2 workflows, I would profit from it to cover the case of multiple from/to and multiple transitions too

Copy link
Member

Choose a reason for hiding this comment

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

I added two more meaningful examples (one taken from @lyrixx' demo application and the other one from the docs written by @Nyholm). I also noticed that there was no way to configure the type of the workflow. This is fixed now. Tests have been expanded too.

@stof
Copy link
Member

stof commented Nov 11, 2016

@lyrixx the DI config does not seem to allow configuring the initial place, according to the XSD schema. Is it expected ?

@HeahDude
Copy link
Contributor

@stof see #20490.

@lyrixx
Copy link
Member

lyrixx commented Nov 15, 2016

I want to merge #20490 first, then could you add the new initial_place, in the fixtures?
Thanks

@xabbuh
Copy link
Member

xabbuh commented Nov 15, 2016

@lyrixx 👍 Just leave a comment here so either @wouterj or me will be able to update the PR accordingly.

lyrixx added a commit that referenced this pull request Nov 15, 2016
…(HeahDude)

This PR was merged into the 3.2-dev branch.

Discussion
----------

[FrameworkBundle] [Workflow] fixed initial place config

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #20458 (comment)
| License       | MIT
| Doc PR        | ~

Commits
-------

91237c9 [FrameworkBundle] [Workflow] Fixed initial place config
@lyrixx
Copy link
Member

lyrixx commented Nov 15, 2016

@xabbuh @wouterj : I just merged the other PR. Thanks.

@xabbuh
Copy link
Member

xabbuh commented Nov 15, 2016

@lyrixx updated here

@lyrixx
Copy link
Member

lyrixx commented Nov 15, 2016

👍

1 similar comment
@stof
Copy link
Member

stof commented Nov 16, 2016

👍

@stof
Copy link
Member

stof commented Nov 16, 2016

Thank you @wouterj.

@stof stof merged commit 94a7e7e into symfony:master Nov 16, 2016
stof added a commit that referenced this pull request Nov 16, 2016
…abbuh)

This PR was merged into the 3.2-dev branch.

Discussion
----------

Added XML support for Workflow configuration

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | symfony/symfony-docs#6871

Commits
-------

94a7e7e [Workflow] streamline XML schema definition
6381caa Added XML support for Workflow configuration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants