-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Workflow] Enter events #21433
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
Comments
@lyrixx ping |
Actually, this event is named Anyway, I have no objection to invert theses two lines But I would like to know your use case before it. |
there is already another event after marking the place: |
Well, lets imagine there is a Feature which has many Tasks. When the last task is closed the feature needs to be approved. In that case it would be convenient to have something like:
And have a listener which listens to "workflow.task.entered.closed" which do the job. But you cannot do that, because in that case you will get entity which is not entered new place yet. Even the name "entered" tells us that an entity entered the place, while this is just about to enter it |
hmm, announce is about newly enabled transitions, not 8000 about the place. So it is not the same event actually. But we should rather add another event if there is a use case for it IMO. changing the behavior of the existing event would break BC, which could do weird things |
@samusenkoiv the event name is not |
@stof ok, so my argument about the name does count then =) |
It would be reasonable to have "before_enter" and "after_enter", but that'd lead to BC breaks too. |
Well, we could add a |
@stof yes we could. Do we agree on that, should I prepare a PR? |
@samusenkoiv #20787 I wanted to do the same thing last month :) |
@lyrixx any thoughts? |
My use case is the following: automatic transitions. For automatic transitions I would now have listeners on the
|
@meDavid Seconded. I needed this too, settled for the announce event. |
@meDavid Indeed, it's better to listen the @samusenkoiv Could you explain why you could not use the |
@lyrixx I do not understand how I can do it with What I would like to have is being notified when an entity has changed its place. Just like https://github.com/symfony/symfony/pull/20787/files solves this in a nice way, why don't like it? |
If you want to auto apply transition, you can have a look at: lyrixx/SFLive-Paris2016-Workflow@9fda92a
The implementations is good. But we already have many events, and If we can avoid to add new events it's better. If there is too many options, it's harder to understand each one. But if there is no solution for this use case, we will add it to the core ;) |
@lyrixx My usecase is indeed resolved using the announce event. |
@lyrixx I do not want to auto apply transition. Yes, I do not see a solution. To be honest, I believe the
We could add an option which would indicate which of the events we'd like to be dispatched. What do you think? I could work on it in case it has chances to be merged. |
No, adding an option is even worst ;) I still don't get your use case. because here it's about auto transition. Could you explain again you use case please? |
@lyrixx well, from some perspective it is indeed about auto transition, but it is about auto transition of another entity. So we have Feature entity which has many Task. When a task is in place "finished" we need to check all the others feature's tasks. If every task is in place "finished" then we can try to mark the feature as "completed". I'll explain:
And with entered event being dispatched after setting marking this would be possible. |
Ok, Nice I understand your use case. What about: public function onTaskFinished(Event $event)
{
// the t2 task
$currentTask = $event->getSubject();
foreach ($task->getFeature()->getTasks() as $task) {
// The current task is finished
if ($task === $currentTask) {
continue;
}
// if at least one task is not finished
if ($task->isFinished() === false) {
return;
}
}
// here I know that all tasks are finished, but they are not, because of the t2 task
} But anyway, even if it is possible to do that I don't like it so much. Because it will mean the Feature is finished before the last Task. Now I'm 👍 for a new event. I will re-open #20787 and review it, and merge it ;) |
Indeed, such a condition is a solution here (although it seems hacky), but it is not possible if we go outside |
Yeah, every sensible decision is really easier with a clear use case. Thanks. |
This PR was submitted for the 3.2 branch but it was merged into the 3.3-dev branch instead (closes #20787). Discussion ---------- [Workflow] Added an entered event | Q | A | ------------- | --- | Branch? | 3.2 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20774 (partially) ; #21433 | License | MIT | Doc PR | - Commits ------- 7a562bd [Workflow] Added an entered event
@lyrixx @meDavid please note that |
Uh oh!
There was an error while loading. Please reload this page.
I found a strange behaviour of Workflow Class. Particularly this part https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Workflow/Workflow.php#L139-L141 . Turns out, if a listener is subscribed on "workflow.entity.enter.place" it will receive the entity when it is not in the "place" yet.
So technically there is no an event like "right-after-a-transition".
Shouldn't we trigger ""workflow.entity.enter" events after changing the place for entity?
The text was updated successfully, but these errors were encountered: