Documentation

Voter
in package
implements VoterInterface, CacheableVoterInterface

AbstractYes

Voter is an abstract default implementation of a voter.

Tags
author

Roman Marintšenko inoryy@gmail.com

author

Grégoire Pineau lyrixx@lyrixx.info

Table of Contents

Interfaces

VoterInterface
VoterInterface is the interface implemented by all voters.
CacheableVoterInterface
Let voters expose the attributes and types they care about.

Methods

supportsAttribute()  : bool
Return false if your voter doesn't support the given attribute. Symfony will cache that decision and won't call your voter again for that attribute.
supportsType()  : bool
Return false if your voter doesn't support the given subject type. Symfony will cache that decision and won't call your voter again for that subject type.
vote()  : int
Returns the vote for the given parameters.
supports()  : bool
Determines if the attribute and subject are supported by this voter.
voteOnAttribute()  : bool
Perform a single access check operation on a given attribute, subject and token.

Methods

supportsAttribute()

Return false if your voter doesn't support the given attribute. Symfony will cache that decision and won't call your voter again for that attribute.

public supportsAttribute(string $attribute) : bool
Parameters
$attribute : string
Return values
bool

supportsType()

Return false if your voter doesn't support the given subject type. Symfony will cache that decision and won't call your voter again for that subject type.

public supportsType(string $subjectType) : bool
Parameters
$subjectType : string

The type of the subject inferred by get_class() or get_debug_type()

Return values
bool

vote()

Returns the vote for the given parameters.

public vote(TokenInterface $token, mixed $subject, array<string|int, mixed> $attributes) : int
Parameters
$token : TokenInterface
$subject : mixed

The subject to secure

$attributes : array<string|int, mixed>

An array of attributes associated with the method being invoked

Return values
int

either ACCESS_GRANTED, ACCESS_ABSTAIN, or ACCESS_DENIED

supports()

Determines if the attribute and subject are supported by this voter.

protected abstract supports(string $attribute,  $subject) : bool
Parameters
$attribute : string
$subject :

The subject to secure, e.g. an object the user wants to access or any other PHP type

Return values
bool

voteOnAttribute()

Perform a single access check operation on a given attribute, subject and token.

protected abstract voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token) : bool

It is safe to assume that $attribute and $subject already passed the "supports()" method check.

Parameters
$attribute : string
$subject : mixed
$token : TokenInterface
Return values
bool

        
On this page

Search results