Answer the question
In order to leave comments, you need to log in
How to assign a user access rights to a function in symfony 2 (is_granted)?
Took the function, according to documentation symfony.com/doc/current/bundles/SensioFrameworkExt...
/**
* @Security("is_granted('POST_SHOW', post)")
*/
public function showAction(Post $post)
{
// somethings
}
Answer the question
In order to leave comments, you need to log in
There are at least 2 options here:
You can use Acl - symfony.com/doc/current/cookbook/security/acl.html
Or create your own Voter - symfony.com/doc/current/cookbook/security/voters_d...
Acl is a universal option , added permission (in your case it will be view) and all
Voter can implement more complex checks, for example, allow COMMENT_EDIT only to its author for 5 minutes. Or universal - Make an interface
interface OwnerableInterface {
/**
* return User
*/
public function getOwner();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question