Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Never use this to check if this user has access to anything!
- *
- * Use the SecurityContext, or an implementation of AccessDecisionManager
- * instead, e.g.
- *
- * $securityContext->isGranted('ROLE_USER');
- *
- * @param string $role
- *
- * @return boolean
- */
- public function hasRole($role)
- {
- return in_array(strtoupper($role), $this->getRoles(), true);
- }
- $data = $form->getData();
- $user = new User();
- $user->setUsername($data->getUsername());
- $user->setExpiresAt($data->getExpiresAt());
- $user->setName($data->getName());
- $user->setPassword($data->getPassword());
- $user->setEmail($data->getEmail());
- $user->setCredentialsExpired($data->isCredentialsExpired());
- $user->setRoles(array('ROLE_NEW'));
- $em->persist($user);
- $em->flush();
- // return false
- var_dump(
- $this->get('security.context')>isGranted('ROLE_NEW',$user));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement