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

Commit8227270

Browse files
Michael Kleinweaverryan
Michael Klein
authored andcommitted
updated according to the review
1 parentda7b97e commit8227270

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

‎cookbook/security/voters_data_permission.rst

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,12 @@ You could implement your Voter to check permission for the view and edit action
7373

7474
public function supportsClass($obj)
7575
{
76-
if ($obj instanceof Post) {
77-
return true;
78-
}
79-
80-
return false;
76+
return $obj instanceof Post;
8177
}
8278

83-
/** @var \Acme\DemoBundle\Entity\Post $post */
79+
/**
80+
* @var \Acme\DemoBundle\Entity\Post $post
81+
*/
8482
public function vote(TokenInterface $token, $post, array $attributes)
8583
{
8684
// check if class of this object is supported by this voter
@@ -89,7 +87,7 @@ You could implement your Voter to check permission for the view and edit action
8987
}
9088

9189
// check if voter is used correct, only allow one attribute for a check
92-
if(count($attributes) !==1 || !is_string($attributes[0])) {
90+
if(1 !==count($attributes) || !is_string($attributes[0])) {
9391
throw new InvalidArgumentException(
9492
'Only one attribute is allowed for VIEW or EDIT'
9593
);
@@ -176,7 +174,7 @@ and tag it as a ``security.voter``:
176174
->register(
177175
'security.access.post_document_voter',
178176
'Acme\DemoBundle\Security\Authorization\Voter\PostVoter'
179-
)
177+
)
180178
->addTag('security.voter')
181179
;
182180
@@ -194,11 +192,12 @@ from the security context is called.
194192
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
195193
use Symfony\Component\HttpFoundation\Response;
196194
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
195+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
196+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
197197
use Acme\DemoBundle\Entity\Post;
198198
199199
class PostController extends Controller
200200
{
201-
202201
/**
203202
* @Route("/blog/{id}")
204203
* @ParamConverter("post", class="SensioBlogBundle:Post")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp