Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Workflow] Added Context to Workflow Event #37539

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

Merged
merged 1 commit into from
Aug 12, 2020

Conversation

epitre
Copy link
Contributor

@epitre epitre commented Jul 9, 2020

There's also a default context for the initial marking event.

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #37421
License MIT
Doc PR symfony/symfony-docs#13947

This time, I need context in the events, because, sometimes, the transition is automatic and sometimes, it is manual. I want to be able to make the difference. I figured using the context for that is a good idea. I hope you do too :)

By the way, I believe it also fixes #37421 . I took @pluk77 request to be able to differentiate an initial marking by having a default context in that case

src/Symfony/Component/Workflow/Event/Event.php Outdated Show resolved Hide resolved
@epitre
Copy link
Contributor Author

epitre commented Jul 9, 2020

appveyor is not happy but I believe it has nothing to do with me. Does it ?

@epitre epitre force-pushed the eventWithContext branch 2 times, most recently from ee4d388 to 348cb02 Compare July 9, 2020 11:07
@epitre epitre changed the title Added Context to Workflow Event [Workflow] Added Context to Workflow Event Jul 9, 2020
src/Symfony/Component/Workflow/WorkflowInterface.php Outdated Show resolved Hide resolved
*/
class Workflow implements WorkflowInterface
{
public const DISABLE_ANNOUNCE_EVENT = 'workflow_disable_announce_event';
public const DEFAULT_INITIAL_CONTEXT = ['initial' => true];
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason you made this an associative array and not an indexed one?
public const DEFAULT_INITIAL_CONTEXT = ['initial'];

I see in one of your tests you did use an indexed array as $context.

Are yuo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this way, you can do :
if ($context['initial']??false)

@lyrixx lyrixx added the Workflow label Jul 9, 2020
Copy link
Member

@lyrixx lyrixx left a comment

Choose a reason for hiding this comment

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

Thanks for your PR but I already rejected in the past

src/Symfony/Component/Workflow/WorkflowInterface.php Outdated Show resolved Hide resolved
src/Symfony/Component/Workflow/Workflow.php Outdated Show resolved Hide resolved
src/Symfony/Component/Workflow/Workflow.php Outdated Show resolved Hide resolved
@epitre
Copy link
Contributor Author

epitre commented Jul 9, 2020

Thanks for your PR but I already rejected in the past

O_O Does it mean you are rejecting this one ?

What I want, is to be able to differentiate transitions that will be done automatically from others that will be done manually.
If not with the context, how do you suggest to do that ?

@epitre epitre force-pushed the eventWithContext branch from 348cb02 to 6ece94a Compare July 9, 2020 14:06
@epitre
Copy link
Contributor Author

epitre commented Jul 9, 2020

Thanks for your PR but I already rejected in the past

I found an old PR and realized the TransitionEvent knows the context ^^

I'll use this event, then. But I really don't understand why the other events do not deserve to know the context ^^

@lyrixx
Copy link
Member

lyrixx commented Jul 9, 2020

Oups, I write the comment but I forgot to remove it 👍

I'm against to put the context in the guard event but for other event I guess this is fine 👍

O_O Does it mean you are rejecting this one ?

nope, it's OK 👍

Sorry for my bad comment

@epitre epitre force-pushed the eventWithContext branch from 6ece94a to f53d995 Compare July 9, 2020 15:09
@epitre
Copy link
Contributor Author

epitre commented Jul 9, 2020

Oups, I write the comment but I forgot to remove it +1

I'm against to put the context in the guard event but for other event I guess this is fine +1

O_O Does it mean you are rejecting this one ?

nope, it's OK +1

Sorry for my bad comment

Great ! So, GuardEvent is not aware of the context anymore. I simplified TransitionEvent. And TransitionEvent is still the only event which can change the context.

@epitre epitre force-pushed the eventWithContext branch 3 times, most recently from 7756024 to 2b1651c Compare July 9, 2020 15:23
@nicolas-grekas nicolas-grekas added this to the next milestone Jul 9, 2020
src/Symfony/Component/Workflow/Event/Event.php Outdated Show resolved Hide resolved
src/Symfony/Component/Workflow/Workflow.php Outdated Show resolved Hide resolved
@@ -395,34 +400,38 @@ private function entered(object $subject, ?Transition $transition, Marking $mark
foreach ($transition->getTos() as $place) {
$this->dispatcher->dispatch($event, sprintf('workflow.%s.entered.%s', $this->name, $place));
}
} elseif (!empty($this->definition->getInitialPlaces())) {
Copy link
Member

Choose a reason for hiding this comment

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

This is not related to the current PR. Could you revert it? thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

without that, the DEFAULT_INITIAL_CONTEXT makes no sense.

it's a little far fetched, but I believe adding this context enhancement is a good moment to add this default context

Unless you don't want a DEFAULT_INITIAL_CONTEXT ?

There's also a default context for the initial marking event.
@epitre epitre force-pushed the eventWithContext branch from 2b1651c to bfe07dd Compare July 9, 2020 22:09
@epitre
Copy link
Contributor Author

epitre commented Jul 20, 2020

@lyrixx up !

@lyrixx
Copy link
Member

lyrixx commented Aug 12, 2020

I'm gonna merge your PR, but I also gonna tweak 2/3 things

Thanks for your work and your patience

@lyrixx
Copy link
Member

lyrixx commented Aug 12, 2020

Thank you @epitre.

@lyrixx lyrixx merged commit 25095d8 into symfony:master Aug 12, 2020
fabpot added a commit that referenced this pull request Aug 12, 2020
This PR was merged into the 5.2-dev branch.

Discussion
----------

[Workflow] Simplify code + Updated README.md

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #37539 (cleaning previous PR)
| License       | MIT
| Doc PR        |

Commits
-------

3268bdb [Workflow] Simplify code + Updated README.md
@epitre
Copy link
Contributor Author

epitre commented Aug 12, 2020

@lyrixx Thank you :)

Could you link me the changes you make, just to be informed, please ?

@lyrixx
Copy link
Member

lyrixx commented Aug 12, 2020

Just above: #37813

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.

Workflow initial_marking is optional and entered event on initial_marking is not dispatched
6 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.