Skip to content

Instantly share code, notes, and snippets.

@redleafar
Last active December 9, 2016 16:58
Show Gist options
  • Save redleafar/2ff36e5f30869051208075dd1f173d8d to your computer and use it in GitHub Desktop.
Save redleafar/2ff36e5f30869051208075dd1f173d8d to your computer and use it in GitHub Desktop.
Get owner from ACL object
public function rutaAction($id)
    {
    	$em = $this->getDoctrine()->getManager();
    
    	$ruta = $em->getRepository('BoosterBiciBundle:Ruta')->findOneById($id);
    	
    	$adminSecurityHandler = $this->container->get('sonata.admin.security.handler');

    	$objectIdentity = ObjectIdentity::fromDomainObject($ruta);
    	$acl = $adminSecurityHandler->getObjectAcl($objectIdentity);
    	
    	foreach ($acl->getObjectAces() as $objAce) {
    		if(128 === $objAce->getMask()){
    		    $ownerUsername = $objAce->getSecurityIdentity()->getUsername();
            }
    	}

    	return $this->render('BoosterBiciBundle:Default:ruta.html.twig',array(
    			'ruta' => $ruta,
    			'ownerusername' => $ownerUsername
    	));  
    
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment