Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f230d0f

Browse filesBrowse files
javiereguiluzfabpot
authored andcommitted
[Security] Make the abstract Voter class implement CacheableVoterInterface
1 parent 6d4e4bd commit f230d0f
Copy full SHA for f230d0f

File tree

1 file changed

+21
-1
lines changed
Filter options
  • src/Symfony/Component/Security/Core/Authorization/Voter

1 file changed

+21
-1
lines changed

‎src/Symfony/Component/Security/Core/Authorization/Voter/Voter.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Authorization/Voter/Voter.php
+21-1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.