Symfony\Component\Security\Core\Authentication\Token\AbstractToken::__construct PHP Méthode

__construct() public méthode

Constructor.
public __construct ( array $roles = [] )
$roles array
    public function __construct(array $roles = array())
    {
        foreach ($roles as $role) {
            if (is_string($role)) {
                $role = new Role($role);
            } elseif (!$role instanceof RoleInterface) {
                throw new \InvalidArgumentException(sprintf('$roles must be an array of strings, or RoleInterface instances, but got %s.', gettype($role)));
            }

            $this->roles[] = $role;
        }
    }

Usage Example

 public function __construct($user, array $attributes = array(), array $roles = array())
 {
     parent::__construct($roles);
     $this->setUser($user);
     $this->casAttributes = $attributes;
     parent::setAuthenticated(true);
 }
All Usage Examples Of Symfony\Component\Security\Core\Authentication\Token\AbstractToken::__construct