public function setIdentity($identity)
    {
        if ($identity instanceof IdentityInterface) {
            $this->_identity = $identity;
        } elseif ($identity === null) {
            $this->_identity = null;
        } else {
            throw new InvalidValueException('The identity object must implement IdentityInterface.');
        }
        $this->_access = [];
    }
public function setIdentity($identity)
    {
        if ($identity instanceof IdentityInterface) {
            $this->_identity = $identity;
        } elseif ($identity === null) {
            $this->_identity = null;
        } else {
            throw new InvalidValueException('The identity object must implement IdentityInterface.');
        }
        $this->_access = [];
    }
public function setIdentity ( $ identity ) { if ( $ identity instanceof IdentityInterface ) { $ this -> _identity = $ identity ; } elseif ( $ identity === null ) { $ this -> _identity = null ; } else { throw new InvalidValueException ( 'The identity object must implement IdentityInterface.' ) ; } $ this -> _access = [ ] ; }
Sets the user identity object.

Note that this method does not deal with session or cookie. You should usually use [[switchIdentity()]]
to change the identity of the current user.

@param IdentityInterface|null $identity the identity object associated with the currently logged user.
If null, it means the current user will be a guest without any associated identity.
@throws InvalidValueException if `$identity` object does not implement [[IdentityInterface]].
Sets the user identity object .