/**
  * {@inheritdoc}
  */
 public function findAcl(ObjectIdentityInterface $oid, array $sids = array())
 {
     $rootOid = $this->objectIdentityFactory->root($oid);
     try {
         $acl = $this->getAcl($oid, $sids, $rootOid);
     } catch (AclNotFoundException $noAcl) {
         try {
             // Try to get ACL for underlying object
             $underlyingOid = $this->objectIdentityFactory->underlying($oid);
             $acl = $this->getAcl($underlyingOid, $sids, $rootOid);
         } catch (\Exception $noUnderlyingAcl) {
             // Try to get ACL for root object
             try {
                 $this->baseAclProvider->cacheEmptyAcl($oid);
                 return $this->baseAclProvider->findAcl($rootOid, $sids);
             } catch (AclNotFoundException $noRootAcl) {
                 throw new AclNotFoundException(sprintf('There is no ACL for %s. The root ACL %s was not found as well.', $oid, $rootOid), 0, $noAcl);
             }
         }
     }
     return $acl;
 }
示例#2
0
 /**
  * Get Acl based on given OID and Parent OID
  *
  * @param ObjectIdentityInterface $oid
  * @param array $sids
  * @param ObjectIdentityInterface $rootOid
  * @return RootBasedAclWrapper|\Symfony\Component\Security\Acl\Model\AclInterface
  */
 protected function getAcl(ObjectIdentityInterface $oid, array $sids, ObjectIdentityInterface $rootOid)
 {
     $acl = $this->baseAclProvider->findAcl($oid, $sids);
     if ($this->baseAclProvider->isReplaceWithUnderlyingAcl($acl)) {
         $underlyingOid = $this->objectIdentityFactory->underlying($oid);
         return $this->getAcl($underlyingOid, $sids, $rootOid);
     }
     try {
         $rootAcl = $this->baseAclProvider->findAcl($rootOid, $sids);
         if ($this->baseAclProvider->isEmptyAcl($acl)) {
             return $rootAcl;
         } else {
             return new RootBasedAclWrapper($acl, $rootAcl);
         }
     } catch (AclNotFoundException $noRootAcl) {
         return $acl;
     }
 }