Esempio n. 1
0
 /**
  * @param SavableModelInterface $model
  * @throws CouldNotPurgeException
  */
 public function purge(SavableModelInterface $model)
 {
     $update = $this->solrClient->createUpdate();
     $update->addDeleteById($model->getId());
     $update->addCommit();
     $result = $this->solrClient->update($update);
     if ($result->getStatus() != 0) {
         throw new CouldNotPurgeException('Model could not purge: ' . $result->getResponse()->getStatusMessage());
     }
 }
 /**
  * @param SavableModelInterface $model
  * @throws CouldNotPurgeException
  */
 public function purge(SavableModelInterface $model)
 {
     $params = ['index' => $this->index, 'type' => $this->type, 'id' => $model->getId()];
     $this->client->delete($params);
 }
Esempio n. 3
0
 /**
  * @param SavableModelInterface $model
  * @throws DirtyModelException
  * @throws NothingDeletedException
  */
 public function purge(SavableModelInterface $model)
 {
     if ($model->isDirty()) {
         throw new DirtyModelException('Dirty model cannot be purged.');
     }
 }
Esempio n. 4
0
 /**
  * @param SavableModelInterface $model
  * @return void
  */
 public function purge(SavableModelInterface $model)
 {
     $this->collection->deleteOne(array('id' => $model->getId()));
     $model->markAsStored();
 }
Esempio n. 5
0
 /**
  * @param SavableModelInterface $model
  * @throws DirtyModelException
  * @throws NothingDeletedException
  */
 public function purge(SavableModelInterface $model)
 {
     if ($model->isDirty()) {
         throw new DirtyModelException('Dirty model cannot be purged.');
     }
     $bindData = array('whereId' => $model->getId());
     $query = $this->pdo->prepare('delete from ' . $this->table . ' where id = :whereId');
     $query->execute($bindData);
     $affectedRowCount = $query->rowCount();
     $query->closeCursor();
     if (!$affectedRowCount) {
         throw new NothingDeletedException(sprintf('Noting deleted from %s with %s id', $this->table, $model->getId()));
     }
 }