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

__construct() public method

Constructor.
public __construct ( string | object $user, mixed $credentials, string $providerKey, array $roles = [] )
$user string | object The user can be a UserInterface instance, or an object implementing a __toString method or the username as a regular string
$credentials mixed The user credentials
$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;

        if ($roles) {
            $this->setAuthenticated(true);
        }
    }

Usage Example

 public function __construct(UserInterface $consoleUser, $providerKey = 'fos_userbundle')
 {
     parent::__construct($consoleUser, '', $providerKey, $consoleUser->getRoles());
 }
All Usage Examples Of Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken::__construct