Exemple #1
0
 public static function getRoleLevel(AdvancedUserInterface $user)
 {
     if ($Roles = $user->getRoles()) {
         foreach ($Roles as $Role) {
             $RoleLevel[] = $Role->getParent();
         }
         return min($RoleLevel);
     }
     return NULL;
 }
 /**
  * @param AdvancedUserInterface $user
  * @param $area
  */
 public function login(AdvancedUserInterface $user, $area)
 {
     $request = $this->container->get('request');
     // $area is the name of the firewall in your security.yml
     $token = new UsernamePasswordToken($user, $user->getPassword(), $area, $user->getRoles());
     $this->container->get("security.token_storage")->setToken($token);
     // Fire the login event
     // Logging the user in above the way we do it doesn't do this automatically
     $event = new InteractiveLoginEvent($request, $token);
     $this->container->get("event_dispatcher")->dispatch('security.interactive_login', $event);
 }