Skip to content

Instantly share code, notes, and snippets.

@ftdysa
Created April 8, 2015 19:01
Show Gist options
  • Save ftdysa/0f7fc9ae49e5af95df46 to your computer and use it in GitHub Desktop.
Save ftdysa/0f7fc9ae49e5af95df46 to your computer and use it in GitHub Desktop.
response from controller event
class SudoListener {
public function onKernelController(FilterControllerEvent $event) {
$controller = $event->getController();
$token = $this->tokenStorage->getToken();
if ($token === null || ($user = $token->getUser()) === null) {
return;
}
if (!is_array($controller)) {
return;
}
if ($controller[0] instanceof SudoControllerInterface) {
$key = UserCacheHelper::getSudoKey($user);
$value = $this->client->get($key);
if (!$value || $value === null) {
$redirect = $this->router->generate('user_sudo');
$event->setController(function() use ($redirect) {
return new RedirectResponse($redirect);
});
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment