Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken::__construct PHP Method

__construct() public method

Constructor.
public __construct ( string | object $user, string $credentials, string $providerKey, array $roles = [] )
$user string | object The username (like a nickname, email address, etc.), or a UserInterface instance or an object implementing a __toString method
$credentials string This usually is the password of the user
$providerKey string The provider key
$roles array
    public function __construct($user, $credentials, $providerKey, array $roles = array())
    {
        parent::__construct($roles);

        if (empty($providerKey)) {
            throw new \InvalidArgumentException('$providerKey must not be empty.');
        }

        $this->setUser($user);
        $this->credentials = $credentials;
        $this->providerKey = $providerKey;

        parent::setAuthenticated(count($roles) > 0);
    }

Usage Example

Exemplo n.º 1
0
 public function __construct($sourceToken, Membership $membership, Project $project)
 {
     if (!$sourceToken instanceof UsernamePasswordToken && !$sourceToken instanceof RememberMeToken) {
         throw new AccessDeniedException('Invalid authentication token');
     }
     parent::__construct($sourceToken->getUser(), $sourceToken->getCredentials(), $sourceToken->getProviderKey(), $sourceToken->getUser()->getRoles());
     $this->membership = $membership;
     $this->masterProject = $project;
 }
All Usage Examples Of Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken::__construct