Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2015
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. /**
  2. * Never use this to check if this user has access to anything!
  3. *
  4. * Use the SecurityContext, or an implementation of AccessDecisionManager
  5. * instead, e.g.
  6. *
  7. * $securityContext->isGranted('ROLE_USER');
  8. *
  9. * @param string $role
  10. *
  11. * @return boolean
  12. */
  13. public function hasRole($role)
  14. {
  15. return in_array(strtoupper($role), $this->getRoles(), true);
  16. }
  17.  
  18. $data = $form->getData();
  19. $user = new User();
  20. $user->setUsername($data->getUsername());
  21. $user->setExpiresAt($data->getExpiresAt());
  22. $user->setName($data->getName());
  23. $user->setPassword($data->getPassword());
  24. $user->setEmail($data->getEmail());
  25. $user->setCredentialsExpired($data->isCredentialsExpired());
  26. $user->setRoles(array('ROLE_NEW'));
  27. $em->persist($user);
  28. $em->flush();
  29. // return false
  30. var_dump(
  31. $this->get('security.context')>isGranted('ROLE_NEW',$user));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement