PHP Класс Webiny\Component\Security\Authorization\Voters\RoleVoter

Наследование: implements Webiny\Component\Security\Authorization\Voters\VoterInterface, use trait Webiny\Component\StdLib\StdLibTrait
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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.

Описание методов

supportsRole() публичный Метод

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.
Результат boolean

supportsUserClass() публичный Метод

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.
Результат boolean True if Voter supports the class, otherwise false.

vote() публичный Метод

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.
Результат integer ACCESS_GRANTED, ACCESS_ABSTAIN or ACCESS_DENIED.