sonata-project/SonataAdminBundle — pull request #590 by mweimerskirch (2012-02-29 17:04:03+00:00)
Title: Inject SecurityContext into Admin classes

In order to have the SecurityContext available in the Admin class (to be more flexible when overriding admin->isGranted(...)) I came up with the solution in this pull request. I'm not entirely sure if this is the best way to do this, so I'd be glad to read your comments.

In my admin classes I can now do things such as:

public function isGranted($name, $object = null)
{
return $this->getSecurityContext()->isGranted('ROLE_ADMIN');
}

I also reverted my two previous patches #584 and #587 and implemented the filter in the business logic instead of in the view. In my opinion this is related to the other change so I put it in the same pull request.