/** * Get from document * * @param DocumentInterface $document * @return $this */ public function fromDocument(DocumentInterface $document) { if (null === ($id = $document->getId())) { throw new PelasticInvalidArgumentException("For accessing GET api your document should provide an ID."); } $this->document = $document; }
/** * Make with all attributes * * @param $index * @param null $type * @param DocumentInterface $document * @param null $id * @param array $params * @return $this */ public function make($index, $type = null, DocumentInterface $document, $id = null, array $params = []) { $this->setIndex($index); if (null !== $type) { $this->setType($type); } if (null !== $id) { $this->setDocumentId($id); } elseif (($id = $document->getId()) !== null) { $this->setDocumentId($id); } if (!empty($params)) { $this->setParams($params); } return $this; }