/** * {@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; }
/** * {@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); // todo: Acl cache must be refactoring due task https://magecore.atlassian.net/browse/BAP-3649 //$this->baseAclProvider->cacheWithUnderlyingAcl($oid); } 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; }
public function testRoot() { $id = $this->factory->root('entity'); $this->assertEquals('entity', $id->getIdentifier()); $this->assertEquals(ObjectIdentityFactory::ROOT_IDENTITY_TYPE, $id->getType()); $id = $this->factory->root('Entity'); $this->assertEquals('entity', $id->getIdentifier()); $this->assertEquals(ObjectIdentityFactory::ROOT_IDENTITY_TYPE, $id->getType()); $id = $this->factory->root($this->factory->get('Entity: Test:TestEntity')); $this->assertEquals('entity', $id->getIdentifier()); $this->assertEquals(ObjectIdentityFactory::ROOT_IDENTITY_TYPE, $id->getType()); $id = $this->factory->root($this->factory->get(new TestEntity(123))); $this->assertEquals('entity', $id->getIdentifier()); $this->assertEquals(ObjectIdentityFactory::ROOT_IDENTITY_TYPE, $id->getType()); $id = $this->factory->root('action'); $this->assertEquals('action', $id->getIdentifier()); $this->assertEquals(ObjectIdentityFactory::ROOT_IDENTITY_TYPE, $id->getType()); $id = $this->factory->root('Action'); $this->assertEquals('action', $id->getIdentifier()); $this->assertEquals(ObjectIdentityFactory::ROOT_IDENTITY_TYPE, $id->getType()); $id = $this->factory->root($this->factory->get('Action: Some Action')); $this->assertEquals('action', $id->getIdentifier()); $this->assertEquals(ObjectIdentityFactory::ROOT_IDENTITY_TYPE, $id->getType()); }
/** * Constructs an ObjectIdentity is used for grant default permissions * if more appropriate permissions are not specified * * @param string $extensionKey The ACL extension key * @return OID */ public function getRootOid($extensionKey) { return $this->objectIdentityFactory->root($extensionKey); }