Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

make method supportsClass() in custom voter compatible with the interface's documentation#3707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
weaverryan merged 1 commit intosymfony:2.3fromxabbuh:issue-3702
Mar 24, 2014
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletionscookbook/security/voters_data_permission.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -64,7 +64,6 @@ edit a particular object. Here's an example implementation::
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Acme\DemoBundle\Entity\Post;

class PostVoter implements VoterInterface
{
Expand All@@ -79,9 +78,11 @@ edit a particular object. Here's an example implementation::
));
}

public function supportsClass($obj)
public function supportsClass($class)
{
return $obj instanceof Post;
$supportedClass = 'Acme\DemoBundle\Entity\Post';

return $supportedClass === $class || is_subclass_of($class, $supportedClass);
}

/**
Expand All@@ -90,7 +91,7 @@ edit a particular object. Here's an example implementation::
public function vote(TokenInterface $token, $post, array $attributes)
{
// check if class of this object is supported by this voter
if (!$this->supportsClass($post)) {
if (!$this->supportsClass(get_class($post))) {
return VoterInterface::ACCESS_ABSTAIN;
}

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp