Exemple #1
0
 /**
  * @param DocumentInterface $document
  * @param string            $index
  */
 public function delete(DocumentInterface $document, $index)
 {
     $deleteQuery = new FindByIdentifierQuery();
     $deleteQuery->setDocument($document);
     $delete = $this->solariumClient->createUpdate();
     $delete->addDeleteQuery($deleteQuery->getQuery());
     $delete->addCommit();
     $this->applyQuery($delete, $index);
 }
 public function testGetQuery_IdMissing()
 {
     $query = new FindByIdentifierQuery();
     $query->setDocument(new Document());
     try {
         $query->getQuery();
         $this->fail('an exception should be thrown');
     } catch (\RuntimeException $e) {
         $this->assertEquals('id should not be null', $e->getMessage());
     }
 }
Exemple #3
0
 /**
  * @param DocumentInterface $document
  * @param string            $index
  */
 public function delete(DocumentInterface $document, $index)
 {
     $documentFields = $document->getFields();
     $documentKey = $documentFields[MetaInformationInterface::DOCUMENT_KEY_FIELD_NAME];
     $deleteQuery = new FindByIdentifierQuery();
     $deleteQuery->setDocument($document);
     $deleteQuery->setDocumentKey($documentKey);
     $delete = $this->solariumClient->createUpdate();
     $delete->addDeleteQuery($deleteQuery->getQuery());
     $delete->addCommit();
     $this->applyQuery($delete, $index);
 }
Exemple #4
0
 /**
  * {@inheritdoc}
  */
 public function find($id)
 {
     $mapper = $this->solr->getMapper();
     $mapper->setMappingCommand($this->solr->getCommandFactory()->get('all'));
     $metaInformation = $this->solr->getMetaFactory()->loadInformation($this->entity);
     $document = $mapper->toDocument($metaInformation);
     $query = new FindByIdentifierQuery();
     $query->setDocument($document);
     $query->setEntity($this->entity);
     $query->setSolr($this->solr);
     $query->setHydrationMode($this->hydrationMode);
     $found = $this->solr->query($query);
     if (count($found) == 0) {
         return null;
     }
     return array_pop($found);
 }
 /**
  * @expectedException \RuntimeException
  * @expectedExceptionMessage id should not be null
  */
 public function testGetQuery_IdMissing()
 {
     $query = new FindByIdentifierQuery();
     $query->setDocument(new Document());
     $query->getQuery();
 }