Reputation: 13
I have a REST API built with the framework Symfony 3.4 (and FOS Rest Bundle). I use the authentication with API keys to authenticate users (https://symfony.com/doc/3.3/security/api_key_authentication.html). I installed the LexikMaintenanceBundle (https://github.com/lexik/LexikMaintenanceBundle) in order to add a maintenance mode to the API.
The issue is the authentication is always done in first, instead of checking first if the maintenance mode is enabled. Normally, the checking of maintenance mode should be done first before the authentication.
How can I change the priority of the listener created in a bundle? Or maybe there is another solution to change it.
Thanks for your help.
Upvotes: 0
Views: 941
Reputation: 1755
You can control the order in which listeners are executed using the additional tag attribute priority
. See the documentation. The higher the number the earlier a listener is executed, default is 0.
You can give the MaintenanceListener
a higher priority (any positive value, e.g. 10) by adding the priority
attribute in LexikMaintenanceBundle/Resources/config/services.xml
:
<tag name="kernel.event_listener" event="kernel.request" method="onKernelRequest" priority="10" />
Upvotes: 1