/** * This regenerates the ancestor table which is used for fast read access. * * @param AclInterface $acl */ private function regenerateAncestorRelations(AclInterface $acl) { $pk = $acl->getId(); $this->connection->executeQuery($this->getDeleteObjectIdentityRelationsSql($pk)); $this->connection->executeQuery($this->getInsertObjectIdentityRelationSql($pk, $pk)); $parentAcl = $acl->getParentAcl(); while (null !== $parentAcl) { $this->connection->executeQuery($this->getInsertObjectIdentityRelationSql($pk, $parentAcl->getId())); $parentAcl = $parentAcl->getParentAcl(); } }
/** * {@inheritdoc} */ public function putInCache(AclInterface $acl) { if (null === $acl->getId()) { throw new \InvalidArgumentException('Transient ACLs cannot be cached.'); } $parentAcl = $acl->getParentAcl(); if (null !== $parentAcl) { $this->putInCache($parentAcl); } $key = $this->createKeyFromIdentity($acl->getObjectIdentity()); $this->cache->save($key, serialize($acl)); $this->cache->save($acl->getId(), $key); }
/** * This updates the parent and ancestors in the identity * * @param AclInterface $acl * @param array $changes * @return void */ protected function updateObjectIdentity(AclInterface $acl, array $changes) { if (isset($changes['entriesInheriting'])) { $updates['entriesInheriting'] = $changes['entriesInheriting'][1]; } if (isset($changes['parentAcl'])) { $query = array('_id' => new \MongoId($acl->getParentAcl()->getId())); $parent = $this->connection->selectCollection($this->options['oid_collection'])->findOne($query); $updates['parent'] = $parent; if (isset($parent['ancestors'])) { $ancestors = $parent['ancestors']; } $ancestors[] = $parent['_id']; $updates['ancestors'] = $ancestors; } if (!isset($updates)) { return; } $entry = array('_id' => new \MongoId($acl->getId())); $newData = array('$set' => $updates); $this->connection->selectCollection($this->options['oid_collection'])->update($entry, $newData); }