Skip to content

Commit 6ef7002

Browse files
javiereguiluzfabpot
authored andcommitted
[Security] Make the abstract Voter class implement CacheableVoterInterface
1 parent dd2f0d0 commit 6ef7002

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

Authorization/Voter/Voter.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @author Roman Marintšenko <inoryy@gmail.com>
2020
* @author Grégoire Pineau <lyrixx@lyrixx.info>
2121
*/
22-
abstract class Voter implements VoterInterface
22+
abstract class Voter implements VoterInterface, CacheableVoterInterface
2323
{
2424
/**
2525
* {@inheritdoc}
@@ -59,6 +59,26 @@ public function vote(TokenInterface $token, $subject, array $attributes)
5959
return $vote;
6060
}
6161

62+
/**
63+
* Return false if your voter doesn't support the given attribute. Symfony will cache
64+
* that decision and won't call your voter again for that attribute.
65+
*/
66+
public function supportsAttribute(string $attribute): bool
67+
{
68+
return true;
69+
}
70+
71+
/**
72+
* Return false if your voter doesn't support the given subject type. Symfony will cache
73+
* that decision and won't call your voter again for that subject type.
74+
*
75+
* @param string $subjectType The type of the subject inferred by `get_class()` or `get_debug_type()`
76+
*/
77+
public function supportsType(string $subjectType): bool
78+
{
79+
return true;
80+
}
81+
6282
/**
6383
* Determines if the attribute and subject are supported by this voter.
6484
*

0 commit comments

Comments
 (0)