diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:31:33 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:31:33 -0400 |
commit | 150f94f051128f367bc89f6b7e5f57eb2a69fc62 (patch) | |
tree | 181f454813b310ee97385058c6c6f2e3f34d5fd8 /vendor/ruflin/elastica/lib/Elastica/Bulk/Action | |
parent | 7e85254903c7c0cb49e381f16b18441ea7b058cc (diff) | |
parent | 80f7dc77d430774192b929d780f96260066df2ee (diff) |
Merge commit '80f7dc'
# Conflicts:
# extensions/ArchInterWiki.sql
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Bulk/Action')
5 files changed, 0 insertions, 327 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/AbstractDocument.php b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/AbstractDocument.php deleted file mode 100644 index 545e695c..00000000 --- a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/AbstractDocument.php +++ /dev/null @@ -1,162 +0,0 @@ -<?php - -namespace Elastica\Bulk\Action; - -use Elastica\AbstractUpdateAction; -use Elastica\Bulk\Action; -use Elastica\Document; -use Elastica\Script; - -abstract class AbstractDocument extends Action -{ - /** - * @var \Elastica\Document|\Elastica\Script - */ - protected $_data; - - /** - * @param \Elastica\Document|\Elastica\Script $document - */ - public function __construct($document) - { - $this->setData($document); - } - - /** - * @param \Elastica\Document $document - * @return \Elastica\Bulk\Action\AbstractDocument - */ - public function setDocument(Document $document) - { - $this->_data = $document; - - $metadata = $this->_getMetadata($document); - - $this->setMetadata($metadata); - - return $this; - } - - /** - * @param \Elastica\Script $script - * @return \Elastica\Bulk\Action\AbstractDocument - */ - public function setScript(Script $script) - { - if (!($this instanceof UpdateDocument)) { - throw new \BadMethodCallException("setScript() can only be used for UpdateDocument"); - } - - $this->_data = $script; - - $metadata = $this->_getMetadata($script); - $this->setMetadata($metadata); - - return $this; - } - - /** - * @param \Elastica\Script|\Elastica\Document $data - * @throws \InvalidArgumentException - * @return \Elastica\Bulk\Action\AbstractDocument - */ - public function setData($data) - { - if ($data instanceof Script) { - - $this->setScript($data); - - }else if ($data instanceof Document) { - - $this->setDocument($data); - - }else{ - throw new \InvalidArgumentException("Data should be a Document or a Script."); - } - - return $this; - } - - /** - * Note: This is for backwards compatibility. - * @return \Elastica\Document - */ - public function getDocument() - { - if ($this->_data instanceof Document) { - return $this->_data; - } - - return null; - } - - /** - * Note: This is for backwards compatibility. - * @return \Elastica\Script - */ - public function getScript() - { - if ($this->_data instanceof Script) { - return $this->_data; - } - - return null; - } - - /** - * @return \Elastica\Document|\Elastica\Script - */ - public function getData() - { - return $this->_data; - } - - /** - * @param \Elastica\AbstractUpdateAction $source - * @return array - */ - abstract protected function _getMetadata(AbstractUpdateAction $source); - - /** - * @param \Elastica\Document|\Elastica\Script $data - * @param string $opType - * @return \Elastica\Bulk\Action\AbstractDocument - */ - public static function create($data, $opType = null) - { - //Check type - if (!($data instanceof Document) && !($data instanceof Script)) { - throw new \InvalidArgumentException("The data needs to be a Document or a Script."); - } - - if (null === $opType && $data->hasOpType()) { - $opType = $data->getOpType(); - } - - //Check that scripts can only be used for updates - if ($data instanceof Script) { - if ($opType === null) { - $opType = self::OP_TYPE_UPDATE; - } else if ($opType != self::OP_TYPE_UPDATE) { - throw new \InvalidArgumentException("Scripts can only be used with the update operation type."); - } - } - - switch ($opType) { - case self::OP_TYPE_DELETE: - $action = new DeleteDocument($data); - break; - case self::OP_TYPE_CREATE: - $action = new CreateDocument($data); - break; - case self::OP_TYPE_UPDATE: - $action = new UpdateDocument($data); - break; - case self::OP_TYPE_INDEX: - default: - $action = new IndexDocument($data); - break; - } - return $action; - } -} diff --git a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/CreateDocument.php b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/CreateDocument.php deleted file mode 100644 index ae868b49..00000000 --- a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/CreateDocument.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -namespace Elastica\Bulk\Action; - -class CreateDocument extends IndexDocument -{ - /** - * @var string - */ - protected $_opType = self::OP_TYPE_CREATE; -} diff --git a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/DeleteDocument.php b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/DeleteDocument.php deleted file mode 100644 index 572f80b6..00000000 --- a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/DeleteDocument.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php - -namespace Elastica\Bulk\Action; - -use Elastica\AbstractUpdateAction; - -class DeleteDocument extends AbstractDocument -{ - /** - * @var string - */ - protected $_opType = self::OP_TYPE_DELETE; - - /** - * @param \Elastica\AbstractUpdateAction $action - * @return array - */ - protected function _getMetadata(AbstractUpdateAction $action) - { - $params = array( - 'index', - 'type', - 'id', - 'version', - 'version_type', - 'routing', - 'parent' - ); - $metadata = $action->getOptions($params, true); - - return $metadata; - } -} diff --git a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/IndexDocument.php b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/IndexDocument.php deleted file mode 100644 index d405563e..00000000 --- a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/IndexDocument.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php - -namespace Elastica\Bulk\Action; - -use Elastica\AbstractUpdateAction; -use Elastica\Bulk\Action; -use Elastica\Document; - -class IndexDocument extends AbstractDocument -{ - /** - * @var string - */ - protected $_opType = self::OP_TYPE_INDEX; - - /** - * @param \Elastica\Document $document - * @return \Elastica\Bulk\Action\IndexDocument - */ - public function setDocument(Document $document) - { - parent::setDocument($document); - - $this->setSource($document->getData()); - - return $this; - } - - /** - * @param \Elastica\AbstractUpdateAction $source - * @return array - */ - protected function _getMetadata(AbstractUpdateAction $action) - { - $params = array( - 'index', - 'type', - 'id', - 'version', - 'version_type', - 'routing', - 'percolate', - 'parent', - 'ttl', - 'timestamp', - 'retry_on_conflict', - ); - $metadata = $action->getOptions($params, true); - - return $metadata; - } -} diff --git a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/UpdateDocument.php b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/UpdateDocument.php deleted file mode 100644 index 4c1dbaa4..00000000 --- a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/UpdateDocument.php +++ /dev/null @@ -1,69 +0,0 @@ -<?php - -namespace Elastica\Bulk\Action; - -use Elastica\Document; -use Elastica\Script; - -/** - * @package Elastica\Bulk\Action - * @link http://www.elasticsearch.org/guide/reference/api/bulk/ - */ -class UpdateDocument extends IndexDocument -{ - /** - * @var string - */ - protected $_opType = self::OP_TYPE_UPDATE; - - /** - * Set the document for this bulk update action. - * @param \Elastica\Document $document - * @return \Elastica\Bulk\Action\UpdateDocument - */ - public function setDocument(Document $document) - { - parent::setDocument($document); - - $source = array('doc' => $document->getData()); - - if ($document->getDocAsUpsert()) { - $source['doc_as_upsert'] = true; - - }else if ($document->hasUpsert()) { - - $upsert = $document->getUpsert()->getData(); - - if (!empty($upsert)) { - $source['upsert'] = $upsert; - } - } - - $this->setSource($source); - - return $this; - } - - /** - * @param \Elastica\Script $script - * @return \Elastica\Bulk\Action\AbstractDocument - */ - public function setScript(Script $script) - { - parent::setScript($script); - - $source = $script->toArray(); - - if ($script->hasUpsert()) { - $upsert = $script->getUpsert()->getData(); - - if (!empty($upsert)) { - $source['upsert'] = $upsert; - } - } - - $this->setSource($source); - - return $this; - } -} |