I need to modify my user object on logout. To do this, I have a security.yml that contains the following (amongst other things) -
#...
logout:
s
You could define your target as a parameter in your parameters.yml or config.yml:
parameters:
logout.target: /
And then reference this value in your security.yml:
logout:
success_handler: my.logout_success_handler
target: %logout.target%
And/or inject it into your logout handler:
my.security.logout_success_handler:
class: My\Security\LogoutSuccessHandler
arguments: ["@security.context", "@doctrine.orm.default_entity_manager", %logout.target%]
And return a RedirectResponse with this value:
// Assign the 3. constructor parameter to the instance variable $logoutTarget
public function onLogoutSuccess(Request $request)
{
// ...
return new RedirectResponse($this->logoutTarget);
}