SensioFrameworkExtraBundle icon indicating copy to clipboard operation
SensioFrameworkExtraBundle copied to clipboard

[RFC] Allow configuration of listeners priority

Open Xymanek opened this issue 7 years ago • 4 comments

Currently all listeners have priority of 0. This makes it impossible (without server definition hacks) to insert another listener between them (for example I needed a listener between param converter and security).

I suggest to change the tags from kernel.event_subscriber to kernel.event_listener and allow for configuration of priority, This can be either though parameters or configuration options. By default put 0 to align with current setup

My only concern is the possible BC break as other libraries might rely on priority being hard coded to zero. On other hand since it's configuration by user/developer it shouldn't that big of problem. Also is removal of \Symfony\Component\EventDispatcher\EventSubscriberInterface a BC break?

I can make a PR

Xymanek avatar Sep 21 '17 11:09 Xymanek

I think I'm also running into this issue when upgrading because of HttpCacheBundle expecting ControllerListener

  [RuntimeException]
  Tag support requires SensioFrameworkExtraBundleΓÇÖs ControllerListener for the annotations. Please install sensio/framework-extra-bundle and add it to your AppKernel.

The-Don-Himself avatar Oct 09 '17 03:10 The-Don-Himself

@The-Don-Himself the problem with not seeing the listener is fixed in https://github.com/FriendsOfSymfony/FOSHttpCacheBundle/pull/395

dbu avatar Nov 07 '17 08:11 dbu

@Xymanek this will be hard to accept due to BC. Can you give us an exact use case for what you need to achieve?

jakzal avatar Nov 09 '17 11:11 jakzal

@jakzal before a user can access a page he needs to pass two checks (in this order):

  1. Is he on a plan that allows use of this page? if not -> 404
  2. Does he have permission to access this page? if not -> 403

I'm using @Security for 2nd and @ParamConverter for 1st. However since they both have same priority it's very hard to put something (feature grant check in my case) between them

Xymanek avatar Nov 09 '17 12:11 Xymanek