retrieve parentAcl in AclProvider::findAcl

* change default inherited value to true to comply with database default value
This commit is contained in:
Toni Uebernickel 2012-01-31 19:27:55 +01:00
parent 4758d7bfb4
commit 7b127b2a5c
3 changed files with 25 additions and 6 deletions

View file

@ -120,7 +120,21 @@ class AclProvider implements AclProviderInterface
}
}
return $this->getAcl($collection, $objectIdentity, $loadedSecurityIdentities);
$parentAcl = null;
$modelObj = ObjectIdentityQuery::create()->findOneByAclObjectIdentity($objectIdentity, $this->connection);
if (null !== $modelObj->getParentObjectIdentityId()) {
$parentObj = $modelObj->getObjectIdentityRelatedByParentObjectIdentityId($this->connection);
try {
$parentAcl = $this->findAcl(new ObjectIdentity($parentObj->getIdentifier(), $parentObj->getAclClass($this->connection)->getType()));
} catch (AclNotFoundException $e) {
/*
* This happens e.g. if the parent ACL is created, but does not contain any ACE by now.
* The ACEs may be applied later on.
*/
}
}
return $this->getAcl($collection, $objectIdentity, $loadedSecurityIdentities, $parentAcl, $modelObj->getEntriesInheriting());
}
/**
@ -149,11 +163,13 @@ class AclProvider implements AclProviderInterface
* @param PropelCollection $collection
* @param ObjectIdentityInterface $objectIdentity
* @param array $loadedSecurityIdentities
* @param AclInterface $parentAcl
* @param bool $inherited
*
* @return Acl
*/
protected function getAcl(PropelCollection $collection, ObjectIdentityInterface $objectIdentity, array $loadedSecurityIdentities = array())
protected function getAcl(PropelCollection $collection, ObjectIdentityInterface $objectIdentity, array $loadedSecurityIdentities = array(), AclInterface $parentAcl = null, $inherited = true)
{
return new Acl($collection, $objectIdentity, $this->permissionGrantingStrategy, $loadedSecurityIdentities);
return new Acl($collection, $objectIdentity, $this->permissionGrantingStrategy, $loadedSecurityIdentities, $parentAcl, $inherited);
}
}

View file

@ -61,7 +61,7 @@ class Acl implements AclInterface
* @param AclInterface $parentAcl
* @param boolean $inherited
*/
public function __construct(PropelCollection $entries, ObjectIdentityInterface $objectIdentity, PermissionGrantingStrategyInterface $permissionGrantingStrategy, array $loadedSecurityIdentities = array(), AclInterface $parentAcl = null, $inherited = false)
public function __construct(PropelCollection $entries, ObjectIdentityInterface $objectIdentity, PermissionGrantingStrategyInterface $permissionGrantingStrategy, array $loadedSecurityIdentities = array(), AclInterface $parentAcl = null, $inherited = true)
{
if ($entries->getModel() !== $this->model) {
throw new AclException(sprintf('The given collection does not contain models of class "%s" but of class "%s".', $this->model, $entries->getModel()));

View file

@ -31,6 +31,7 @@ use Propel\PropelBundle\Security\Acl\Domain\Entry;
use Symfony\Component\Security\Acl\Exception\AclAlreadyExistsException;
use Symfony\Component\Security\Acl\Exception\Exception as AclException;
use Symfony\Component\Security\Acl\Model\AclInterface;
use Symfony\Component\Security\Acl\Model\FieldEntryInterface;
use Symfony\Component\Security\Acl\Model\AclCacheInterface;
use Symfony\Component\Security\Acl\Model\MutableAclInterface;
@ -263,11 +264,13 @@ class MutableAclProvider extends AclProvider implements MutableAclProviderInterf
* @param PropelCollection $collection
* @param ObjectIdentityInterface $objectIdentity
* @param array $loadedSecurityIdentities
* @param AclInterface $parentAcl
* @param bool $inherited
*
* @return MutableAcl
*/
protected function getAcl(PropelCollection $collection, ObjectIdentityInterface $objectIdentity, array $loadedSecurityIdentities = array())
protected function getAcl(PropelCollection $collection, ObjectIdentityInterface $objectIdentity, array $loadedSecurityIdentities = array(), AclInterface $parentAcl = null, $inherited = true)
{
return new MutableAcl($collection, $objectIdentity, $this->permissionGrantingStrategy, $loadedSecurityIdentities);
return new MutableAcl($collection, $objectIdentity, $this->permissionGrantingStrategy, $loadedSecurityIdentities, $parentAcl, $inherited, $this->connection);
}
}