public function fetch($hash, $class, $username)
 {
     $classMetadata = $this->metadataManager->loadByClassname($class);
     if (!$this->storageAdapter->contains($hash, $classMetadata->getContext())) {
         throw new ObjectNotFoundException($hash);
     }
     $data = $this->storageAdapter->fetch($hash, $classMetadata->getContext());
     if (array_key_exists('type', $data) && $data['type'] === 'backup') {
         /** @var PolicyCollectionInterface $policyCollection */
         $policyCollection = unserialize($data['policies']);
         /** @var ReplicatorPolicy $policy */
         $policy = $policyCollection->get(self::POLICY_NAME);
         throw new NotPrimaryServerException($policy->getPrimaryServer());
     }
     // TODO security-checker with given username ("%s::%s", server, username)
     return $data;
 }
 /**
  * @dataProvider adapterProvider
  *
  * @param StorageAdapterInterface $storageAdapter
  * @param string $hash
  * @param array $data
  * @param string $context
  */
 public function testDeleteAllWithoutContext(StorageAdapterInterface $storageAdapter, $hash, $data, $context)
 {
     $hash2 = 'hash2';
     $data2 = 'data2';
     $context2 = 'context2';
     $this->assertTrue($storageAdapter->store($hash, $data, $context));
     $this->assertTrue($storageAdapter->store($hash2, $data2, $context2));
     $this->assertTrue($storageAdapter->deleteAll());
     $this->assertFalse($storageAdapter->contains($hash, $context));
     $this->assertFalse($storageAdapter->contains($hash2, $context2));
 }
Esempio n. 3
0
 public function deleteAll()
 {
     $this->storageAdapter->deleteAll();
     $this->searchAdapter->deindexAll();
 }