From 1542416b4b5b8f54530c192dad7fb7dcef3673b8 Mon Sep 17 00:00:00 2001 From: Dylan Date: Wed, 7 Feb 2024 15:28:31 +0100 Subject: [PATCH] updated documentation for CacheableVoterInterface --- security/voters.rst | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/security/voters.rst b/security/voters.rst index a770e386c02..770e373a0d2 100644 --- a/security/voters.rst +++ b/security/voters.rst @@ -35,17 +35,28 @@ The Voter Interface ------------------- A custom voter needs to implement -:class:`Symfony\\Component\\Security\\Core\\Authorization\\Voter\\VoterInterface` +:class:`Symfony\\Component\\Security\\Core\\Authorization\\Voter\\VoterInterface`, +:class:`Symfony\\Component\\Security\\Core\\Authorization\\Voter\\CacheableVoterInterface` or extend :class:`Symfony\\Component\\Security\\Core\\Authorization\\Voter\\Voter`, which makes creating a voter even easier:: use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; - abstract class Voter implements VoterInterface + abstract class Voter implements VoterInterface, CacheableVoterInterface { abstract protected function supports(string $attribute, $subject) bool; abstract protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool; + + public function supportsAttribute(string $attribute): bool + { + return true; + } + + public function supportsType(string $subjectType): bool + { + return true; + } } .. _how-to-use-the-voter-in-a-controller: