Skip to content

Added missing events description #7528

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

Closed
wants to merge 3 commits into from
Closed

Added missing events description #7528

wants to merge 3 commits into from

Conversation

Guite
Copy link
Contributor

@Guite Guite commented Feb 24, 2017

This PR adds descriptions for all events dispatched by the workflow component.

Copy link
Member

@javiereguiluz javiereguiluz left a comment

Choose a reason for hiding this comment

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

@Guite thanks for your contribution!

Although I don't use the Workflow component, I've proposed some changes. The reason is that we must be extra careful when describing an event to explain exactly when it's triggered. That's why I used "just before" and "just after" in the description. Please tell me if I did it right. Thanks!

@Guite
Copy link
Contributor Author

Guite commented Feb 27, 2017

@javiereguiluz looks fine for me, but should be reviewed by someone who is more experienced with the internals.

The following events are dispatched for all workflows:

* ``workflow.guard``: occurs just before starting a transition. It allows you to
prevent the transition by calling ``$event->setBlocked(true);`` as shown above.
Copy link
Contributor

@HeahDude HeahDude Feb 27, 2017

Choose a reason for hiding this comment

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

It is also fired when testing available transitions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@HeahDude added


* ``workflow.guard``: occurs just before starting a transition. It allows you to
prevent the transition by calling ``$event->setBlocked(true);`` as shown above.
* ``workflow.leave``: occurs just after an object has left it's current state.
Copy link
Contributor

Choose a reason for hiding this comment

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

We should mention that all events give carries the subject and the transition.
Also I think we should clarify what state is available in the event:

* ``workflow.leave``: carries the marking with the initial places, occurs just before the transition.
* ``workflow.transition``: carries the marking with the current places, occurs during the transition.
* ``workflow.enter``: carries the marking with the new places, occurs just after the transition.

Actually while checking this I've opened symfony/symfony#21793.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@HeahDude added

Copy link
Contributor

@HeahDude HeahDude left a comment

Choose a reason for hiding this comment

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

Thanks @Guite, I've made some other comments, but please wait for other members opinion before doing any changes, as we also need to see if symfony/symfony#21793 gets merged.

* ``workflow.transition``: occurs just before starting to transition to the new state.
* ``workflow.enter``: occurs just after the object has entered into the new state.
* ``workflow.guard``: occurs just before a transition is started and when testing which transitions are available. It allows you to define that the transition is not allowed by calling ``$event->setBlocked(true);`` as shown above.
* ``workflow.leave``: carries the marking with the initial places, occurs just after an object has left it's current state.
Copy link
Contributor

Choose a reason for hiding this comment

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

it's => its.

To avoid confusion, maybe we should not use "initial" and say something like:
carries the marking with the places held before an object leaves it's current state.

* ``workflow.enter``: occurs just after the object has entered into the new state.
* ``workflow.guard``: occurs just before a transition is started and when testing which transitions are available. It allows you to define that the transition is not allowed by calling ``$event->setBlocked(true);`` as shown above.
* ``workflow.leave``: carries the marking with the initial places, occurs just after an object has left it's current state.
* ``workflow.transition``: carries the marking with the current places, occurs just before starting to transition to the new state.
Copy link
Contributor

Choose a reason for hiding this comment

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

carries the marking with the places held just after leaving the previous state, and just before entering into the new state.

* ``workflow.guard``: occurs just before a transition is started and when testing which transitions are available. It allows you to define that the transition is not allowed by calling ``$event->setBlocked(true);`` as shown above.
* ``workflow.leave``: carries the marking with the initial places, occurs just after an object has left it's current state.
* ``workflow.transition``: carries the marking with the current places, occurs just before starting to transition to the new state.
* ``workflow.enter``: carries the marking with the new places, occurs just after the object has entered into the new state.
Copy link
Contributor

Choose a reason for hiding this comment

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

This one needs no "correction", but to be consistent with others, what about:
carries the marking with the places held after the object has entered into the new state.

Copy link
Contributor

Choose a reason for hiding this comment

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

So symfony/symfony#21793 is merged now and this should be reworded to:

carries the marking with the current places, occurs just before the object enters into the new places.

lyrixx added a commit to symfony/symfony that referenced this pull request Mar 8, 2017
…HeahDude)

This PR was merged into the 3.2 branch.

Discussion
----------

[Workflow] Fixed marking state on leave and enter events

| Q             | A
| ------------- | ---
| Branch?       | 3.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | ~
| License       | MIT
| Doc PR        | related to symfony/symfony-docs#7528

It seems weird to me to dispatch an event while the marking is not yet marked by the new places.
The event is still "marked" by old places when leaving occurs, my guess is that the symmetry should be mirrored.

Do you agree? Should I add a test?

Commits
-------

175858a [Workflow] Fixed marking state on leave and enter events
@lyrixx
Copy link
Member

lyrixx commented Mar 8, 2017

The PR has been merged.

And BTW, if you can add a note in the doc about symfony/symfony#21925 it would be awesome !

@HeahDude
Copy link
Contributor

HeahDude commented Mar 9, 2017

The change @lyrixx suggests should be done in another PR targeting master since this one needs to be merged in 3.2.

@HeahDude HeahDude added this to the 3.2 milestone Mar 9, 2017
@Guite Guite changed the base branch from master to 3.3 August 4, 2017 14:01
@javiereguiluz
Copy link
Member

This is ready for the final review. Thanks!

@Guite
Copy link
Contributor Author

Guite commented Aug 4, 2017

This is rebased for 3.3 now.

Should I add entered and accounce, too? (since these events have been introduced in 3.3, too, I think)

@xabbuh
Copy link
Member

xabbuh commented Aug 9, 2017

I think this should be rearranged to fit with the existing Using Events section.

@Guite
Copy link
Contributor Author

Guite commented Aug 9, 2017

@xabbuh you are right.

I think this one can be closed, since the existing section covers the whole topic already.

@xabbuh
Copy link
Member

xabbuh commented Aug 9, 2017

@Guite Thanks for the feedback. Closing then. If you want to add more information to the existing section, please feel free to create new PRs. :)

@xabbuh xabbuh closed this Aug 9, 2017
@Guite Guite deleted the workflow-events branch August 9, 2017 12:54
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.

6 participants