PHP Class Webiny\Component\Security\Authorization\Voters\AuthenticationVoter

Inheritance: implements Webiny\Component\Security\Authorization\Voters\VoterInterface
Show file Open project: Webiny/Framework Class Usage Examples

Public Methods

Method Description
supportsRole ( Role $role ) : boolean This function is called before we ask the voter to vote.
supportsUserClass ( string $userClassName ) : boolean Voter method that checks if current voter supports the given User class.
vote ( AbstractUser $user, array $requestedRoles ) : integer This function gets the current user object and needs to validate its access against the required roles.

Method Details

supportsRole() public method

The voter will get a list of user roles, and can loop through it to check if it supports the roles, eg. based on their prefix. If the voter returns false, we will not ask him to vote, if it returns true, the voter must vote.
public supportsRole ( Role $role ) : boolean
$role Webiny\Component\Security\Role\Role A Role instances that the current route requires.
return boolean

supportsUserClass() public method

Voter method that checks if current voter supports the given User class.
public supportsUserClass ( string $userClassName ) : boolean
$userClassName string Fully qualified name of the user class with namespace.
return boolean True if Voter supports the class, otherwise false.

vote() public method

The function must either return ACCESS_GRANTED, ACCESS_ABSTAIN or ACCESS_DENIED.
public vote ( AbstractUser $user, array $requestedRoles ) : integer
$user Webiny\Component\Security\User\AbstractUser Current user instance.
$requestedRoles array An array of requested roles for the current access map.
return integer ACCESS_GRANTED, ACCESS_ABSTAIN or ACCESS_DENIED.