public function __construct(DocumentInterface $document)
 {
     $this->document = $document;
     $this->index = $document->getIndex();
     $this->type = $document->getType();
     $this->id = $document->id;
 }
示例#2
0
 /**
  * Store a Document in the repository, but only if it already
  * exists. The document must have an ID.
  *
  * @param Document $document The document to store
  *
  * @return bool True if stored, otherwise false
  */
 public function update(DocumentInterface $document)
 {
     if (!$document->getId()) {
         return false;
     }
     $oldPath = $this->getPathForDocument($document->getInitialId());
     if (!file_exists($oldPath)) {
         return false;
     }
     // If the ID has changed we need to delete the old document.
     if ($document->getId() !== $document->getInitialId()) {
         if (file_exists($oldPath)) {
             unlink($oldPath);
         }
     }
     return $this->store($document);
 }
示例#3
0
 /**
  * Store a document
  *
  * @param DocumentInterface $document
  */
 public function store(DocumentInterface $document)
 {
     $collection = $this->connection->selectCollection($document::getCollectionName());
     $data = $document->allPrepared()->getArray();
     $collection->save($data);
 }
示例#4
0
 /**
  * {@inheritdoc}
  */
 public function AcceptPageBreak()
 {
     $this->document->buildAcceptPageBreak();
     return $this;
 }