File tree 1 file changed +5
-4
lines changed
1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,6 @@ edit a particular object. Here's an example implementation::
64
64
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
65
65
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
66
66
use Symfony\Component\Security\Core\User\UserInterface;
67
- use Acme\DemoBundle\Entity\Post;
68
67
69
68
class PostVoter implements VoterInterface
70
69
{
@@ -79,9 +78,11 @@ edit a particular object. Here's an example implementation::
79
78
));
80
79
}
81
80
82
- public function supportsClass($obj )
81
+ public function supportsClass($class )
83
82
{
84
- return $obj instanceof Post;
83
+ $supportedClass = 'Acme\DemoBundle\Entity\Post';
84
+
85
+ return $supportedClass === $class || is_subclass_of($class, $supportedClass);
85
86
}
86
87
87
88
/**
@@ -90,7 +91,7 @@ edit a particular object. Here's an example implementation::
90
91
public function vote(TokenInterface $token, $post, array $attributes)
91
92
{
92
93
// check if class of this object is supported by this voter
93
- if (!$this->supportsClass($post)) {
94
+ if (!$this->supportsClass(get_class( $post) )) {
94
95
return VoterInterface::ACCESS_ABSTAIN;
95
96
}
96
97
You can’t perform that action at this time.
0 commit comments