session = $session; $this->urlGenerator = $urlGenerator; } public function beforeController($controller, $methodName) { if ($this->session->exists('clearingExecutionContexts')) { throw new ReloadExecutionException(); } } public function afterException($controller, $methodName, \Exception $exception) { if ($exception instanceof ReloadExecutionException) { $this->session->remove('clearingExecutionContexts'); return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute( 'core.login.showLoginForm', ['clear' => true] // this param the code in login.js may be removed when the "Clear-Site-Data" is working in the browsers )); } return parent::afterException($controller, $methodName, $exception); } }