-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Added docs for Workflow component #6871
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
Changes from 1 commit
d0701f0
91867c2
69bca59
f99fbb2
e797f0c
5b2a029
196baf9
763950d
cead2f7
e0089c5
48de43d
805b237
f57ec14
03925ff
e6bdee6
c7464c7
83d26c1
6e7a35f
4415466
866b25a
dceebec
b959f8a
b45edf2
fefdb5f
7f0f5b0
c681283
86ecf0a
d002a8b
b0a8855
4e7cf11
3aa433d
4f277dc
2511c21
c9b1656
2cc2934
47dc11d
3250621
c0bd6da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,45 +11,59 @@ one place simultaneously. It is also worth noting that a workflow does not | |
commonly have cyclic path in the definition graph but it is common for a state | ||
machine. | ||
|
||
Example of state machine | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Example of a State Machine" |
||
------------------------ | ||
|
||
Consider the states a GitHub pull request may have. We have an initial "start" | ||
state, a state for running tests on "travis", then we have the "review" state | ||
where we can require changes, reject or accept the pull request. At anytime we | ||
could also "update" the pull request which will result in another "travis" run. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove the first-person usage: A pull request starts in an intial "start" state, a state for e.g. running
tests on Travis. When this is finished, the pull request is in the "review"
state, where contributors can require changes, reject or accept the
pull request. At any time, you can also "update" the pull request, which
will result in another Travis run. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you |
||
|
||
.. image:: /_images/components/workflow/pull_request.png | ||
|
||
Below is the configuration for the pull request state machine. | ||
|
||
.. configuration-block:: | ||
|
||
.. code-block:: yaml | ||
|
||
framework: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add |
||
workflows: | ||
blog_publishing: | ||
type: | ||
type: 'state_machine' | ||
supports: | ||
- AppBundle\Entity\BlogPost | ||
places: | ||
- draft | ||
pull_request: | ||
type: 'state_machine' | ||
marking_store: | ||
type: scalar | ||
supports: | ||
- AppBundle\Entity\PullRequest | ||
places: | ||
- start | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've started with many comments, so here a resume of what I suggest for the following: pull_request:
type: 'state_machine'
supports:
- AppBundle\Entity\PullRequest
places:
- started
- coding
- travis
- needs_review
- reviewed
- merged
- closed
transitions:
test:
from: [started, coding]
to: travis
submit:
from: travis
to: needs_review
request_change:
from: [travis, needs_review, reviewed]
to: coding
accept:
from: needs_review
to: reviewed
reject:
from: [coding, needs_review, reviewed]
to: closed
reopen:
from: closed
to: needs_review
merge:
from: reviewed
to: merged Wdyt? Actually when trying to dump it I've found a bug and submitted symfony/symfony#20497 :) |
||
- coding | ||
- travis | ||
- review | ||
- rejected | ||
- published | ||
transitions: | ||
to_review: | ||
from: [draft, rejected] | ||
to: review | ||
publish: | ||
- merged | ||
- closed | ||
transitions: | ||
submit: | ||
from: start | ||
to: travis | ||
update: | ||
from: [coding, travis, review] | ||
to: travis | ||
wait_for_reivew: | ||
from: travis | ||
to: review | ||
change_needed: | ||
from: review | ||
to: published | ||
reject: | ||
to: coding | ||
accepted: | ||
from: review | ||
to: rejected | ||
|
||
|
||
With the configuration above we allow an object in place ``draft`` **or** | ||
``rejected`` to be moved to ``review``. If the marking store had been of | ||
type ``scalar`` the object had to be in **both** places. :: | ||
|
||
$workflow = $this->container->get('state_machine.blog_publishing'); | ||
$post = new \BlogPost(); | ||
|
||
$post->state = 'draft'; | ||
$workflow->can($post, 'to_review'); // True | ||
to: merged | ||
rejected: | ||
from: review | ||
to: closed | ||
reopened: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about renaming the last four transitions to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 You are correct |
||
from: closed | ||
to: review | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add XML and PHP formats. <!-- app/config/config.xml -->
<?xml version="1.0" encoding="utf-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"
>
<framework:config>
<framework:workflow name="pull_request" type="state_machine">
<framework:marking-store type="scalar"/>
<framework:support>AppBundle\Entity\PullRequest</framework:support>
<framework:place>start</framework:place>
<framework:place>coding</framework:place>
<framework:place>travis</framework:place>
<framework:place>review</framework:place>
<framework:place>merged</framework:place>
<framework:place>closed</framework:place>
<framework:transition name="submit">
<framework:from>start</framework:from>
<framework:to>travis</framework:to>
</framework:transition>
<framework:transition name="update">
<framework:from>coding</framework:from>
<framework:from>travis</framework:from>
<framework:from>review</framework:from>
<framework:to>travis</framework:to>
</framework:transition>
<framework:transition name="wait_for_review">
<framework:from>travis</framework:from>
<framework:to>review</framework:to>
</framework:transition>
<framework:transition name="change_needed">
<framework:from>review</framework:from>
<framework:to>coding</framework:to>
</framework:transition>
<framework:transition name="accepted">
<framework:from>review</framework:from>
<framework:to>merged</framework:to>
</framework:transition>
<framework:transition name="rejected">
<framework:from>review</framework:from>
<framework:to>closed</framework:to>
</framework:transition>
<framework:transition name="reopened">
<framework:from>closed</framework:from>
<framework:to>review</framework:to>
</framework:transition>
</framework:workflow>
</framework:config>
</container> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you. Im embarrassingly bad at the XML syntax for the config. |
||
|
||
$post->state = 'rejected'; | ||
$workflow->can($post, 'to_review'); // True | ||
|
||
.. _Petri net: https://en.wikipedia.org/wiki/Petri_net |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"[...] definition graph, but it [...]"