Skip to content

Instantly share code, notes, and snippets.

@0xPr0xy
Created May 13, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xPr0xy/079d5d79f6de86854327 to your computer and use it in GitHub Desktop.
Save 0xPr0xy/079d5d79f6de86854327 to your computer and use it in GitHub Desktop.
service
/**
* @param ContainerInterface $container The Container
* @param Request $request The Request
* @param RenderContext $context The Render context
*
* @return void|RedirectResponse
*/
public function service(ContainerInterface $container, Request $request, RenderContext $context)
{
$security = $container->get('security.context');
$user = $security->getToken()->getUser();
$hasUserRole = $security->isGranted('ROLE_USER');
if($user && $hasUserRole){
$context['user'] = $user;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment