Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[Workflow] Add PHP attributes to register listeners and guards#51210

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nicolas-grekas merged 1 commit intosymfony:6.4fromlyrixx:workflow-attributes
Aug 3, 2023

Conversation

@lyrixx
Copy link
Member

@lyrixxlyrixx commentedAug 1, 2023
edited
Loading

QA
Branch?6.4
Bug fix?no
New feature?yes
Deprecations?no
Tickets
LicenseMIT
Doc PR

Allow this:

diff --git a/src/EventSubscriber/TransitionEventSubscriber.php b/src/EventSubscriber/TransitionEventSubscriber.phpindex 3897e54..4ea0d46 100644--- a/src/EventSubscriber/TransitionEventSubscriber.php+++ b/src/EventSubscriber/TransitionEventSubscriber.php@@ -2,18 +2,19 @@  namespace App\EventSubscriber;-use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\User\UserInterface;+use Symfony\Component\Workflow\Attribute\AsTransitionListener; use Symfony\Component\Workflow\Event\TransitionEvent;-class TransitionEventSubscriber implements EventSubscriberInterface+class TransitionEventSubscriber {     public function __construct(         private readonly TokenStorageInterface $tokenStorage,     ) {     }+    #[AsTransitionListener()]     public function onWorkflowArticleTransition(TransitionEvent $event): void     {         $context = $event->getContext();

All theses syntax are supported:

#[AsTransitionListener()]#[AsTransitionListener(workflow:'my-workflow')]#[AsTransitionListener(workflow:'my-workflow', transition:'some-transition')]publicfunction onWorkflowArticleTransition(TransitionEvent$event):void

Note: This is not possible to validate the workflow name,nor the transition name, because workflow can be build dynamically

valtzu reacted with thumbs up emoji
@lyrixx
Copy link
MemberAuthor

@nicolas-grekas Thanks for the review. I addressed your comments

@nicolas-grekasnicolas-grekas changed the title[Workflow] Add some PHP attributes to register listeners and guards[Workflow] Add PHP attributes to register listeners and guardsAug 1, 2023
Copy link
Contributor

@HeahDudeHeahDude left a comment

Choose a reason for hiding this comment

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

👍

@nicolas-grekas
Copy link
Member

Thank you@lyrixx.

@nicolas-grekasnicolas-grekas merged commit623e921 intosymfony:6.4Aug 3, 2023
int$priority =0,
string$dispatcher =null,
) {
parent::__construct($this->buildEventName('announce','transition',$workflow,$transition),$method,$priority,$dispatcher);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
parent::__construct($this->buildEventName('announce','transition',$workflow,$transition),$method,$priority,$dispatcher);
parent::__construct(self::buildEventName('announce','transition',$workflow,$transition),$method,$priority,$dispatcher);

(same for other attributes)

Copy link
Member

@nicolas-grekasnicolas-grekasAug 3, 2023
edited
Loading

Choose a reason for hiding this comment

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

static:: then nvm, private method

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

+1 more reviewer

@HeahDudeHeahDudeHeahDude approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

6.4

Development

Successfully merging this pull request may close these issues.

4 participants

@lyrixx@nicolas-grekas@HeahDude@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp