@@ -73,14 +73,12 @@ You could implement your Voter to check permission for the view and edit action
73
73
74
74
public function supportsClass($obj)
75
75
{
76
- if ($obj instanceof Post) {
77
- return true;
78
- }
79
-
80
- return false;
76
+ return $obj instanceof Post;
81
77
}
82
78
83
- /** @var \Acme\DemoBundle\Entity\Post $post */
79
+ /**
80
+ * @var \Acme\DemoBundle\Entity\Post $post
81
+ */
84
82
public function vote(TokenInterface $token, $post, array $attributes)
85
83
{
86
84
// 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
89
87
}
90
88
91
89
// 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])) {
93
91
throw new InvalidArgumentException(
94
92
'Only one attribute is allowed for VIEW or EDIT'
95
93
);
@@ -176,7 +174,7 @@ and tag it as a ``security.voter``:
176
174
->register(
177
175
'security.access.post_document_voter',
178
176
'Acme\DemoBundle\Security\Authorization\Voter\PostVoter'
179
- )
177
+ )
180
178
->addTag('security.voter')
181
179
;
182
180
@@ -194,11 +192,12 @@ from the security context is called.
194
192
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
195
193
use Symfony\Component\HttpFoundation\Response;
196
194
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
195
+ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
196
+ use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
197
197
use Acme\DemoBundle\Entity\Post;
198
198
199
199
class PostController extends Controller
200
200
{
201
-
202
201
/**
203
202
* @Route("/blog/{id}")
204
203
* @ParamConverter("post", class="SensioBlogBundle:Post")
0 commit comments