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

__construct() public method

Constructor.
public __construct ( string $secret, string | object $user, array $roles = [] )
$secret string A secret used to make sure the token is created by the app and not by a malicious client
$user string | object The user can be a UserInterface instance, or an object implementing a __toString method or the username as a regular string
$roles array An array of roles
    public function __construct($secret, $user, array $roles = array())
    {
        parent::__construct($roles);

        $this->secret = $secret;
        $this->setUser($user);
        $this->setAuthenticated(true);
    }

Usage Example

Beispiel #1
0
 /**
  * Constructor.
  *
  * @codeCoverageIgnore
  *
  * @param string          $key   The key shared with the authentication provider
  * @param string          $user  The user
  * @param RoleInterface[] $roles An array of roles
  */
 public function __construct($key, $user, array $roles = array())
 {
     parent::__construct($key, $user, $roles);
     $this->setAuthenticated(true);
 }
All Usage Examples Of Symfony\Component\Security\Core\Authentication\Token\AnonymousToken::__construct