-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Workflow] Override guard listener class #29751
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
Conversation
f914940
to
b97ef81
Compare
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.
Thanks for the PR. Here are some comments. Please note that this would be considered as a new feature, thus it should target master.
private $trustResolver; | ||
private $roleHierarchy; | ||
private $validator; | ||
protected $configuration; |
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.
That's a no-go: we strongly favor private properties because it helps maintenance a lot.
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.
Thanks for the feedback. So as I understand it, it is preferable to create my own new class completely override the listener.guard services declaration.
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.
yes - you can decorate the core listener if it serves your purpose, but only via composition, ie using its public API.
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.
Since there is a no-go on changing the GuardListener properties visibility and there is other ways to serve my purpose, it seems this pull request can be closed
Hello, More over, as @nicolas-grekas told you, we will not change the properties visibility. Finally, the GuardListener is quite small, you can easily copy it to your projet. In Symfony we have some legacy code, see #24454 ; Your guard will be simpler. So for now I'm 👎 with this PR |
Closing as explained, thanks for proposing! |
Visibility of properties ans dome methods of the GuardListener make difficult to customize workflow guard configuration.
I would like to add the inheritance of the GuardListener along with the possibility to override the default class.
Configuration allow to globally override default Symfony GuardListener with a workflow.guard_listener parameter or for a single workflow through a guard_listener configuration option.
In the next configuration exemple, both workflow.issue.listener.guard and workflow.pull_request.listener.guard are instances of AppBundle\EventListener\GuardListener:
In the next configuration exemple, only workflow.issue.listener.guard is an instance of AppBundle\EventListener\GuardListener: