I have my class MyTwigExtension extends \Twig_Extension, where i have created my filters for twig. I want to use a service in the implementation of a new filter. Something like this:
$canView = $this->get('security_service')
->hasClassPermission(
'MyBundle:MyEntity',
$this->get('security.context')->getToken()->getUser(),
array(MaskBuilder::MASK_VIEW)
);
Into a controller this work fine, but outside it...