From 1a365e77dfb8825136626202b1df462731b42060 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 16 Aug 2015 08:22:05 +0200 Subject: Update to MediaWiki 1.25.2 --- vendor/ruflin/elastica/lib/Elastica/Request.php | 200 ++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 vendor/ruflin/elastica/lib/Elastica/Request.php (limited to 'vendor/ruflin/elastica/lib/Elastica/Request.php') diff --git a/vendor/ruflin/elastica/lib/Elastica/Request.php b/vendor/ruflin/elastica/lib/Elastica/Request.php new file mode 100644 index 00000000..6c6298be --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/Request.php @@ -0,0 +1,200 @@ + + */ +class Request extends Param +{ + const HEAD = 'HEAD'; + const POST = 'POST'; + const PUT = 'PUT'; + const GET = 'GET'; + const DELETE = 'DELETE'; + + /** + * @var \Elastica\Connection + */ + protected $_connection; + + /** + * Construct + * + * @param string $path Request path + * @param string $method OPTIONAL Request method (use const's) (default = self::GET) + * @param array $data OPTIONAL Data array + * @param array $query OPTIONAL Query params + * @param Connection $connection + * @return \Elastica\Request OPTIONAL Connection object + */ + public function __construct($path, $method = self::GET, $data = array(), array $query = array(), Connection $connection = null) + { + $this->setPath($path); + $this->setMethod($method); + $this->setData($data); + $this->setQuery($query); + + if ($connection) { + $this->setConnection($connection); + } + } + + /** + * Sets the request method. Use one of the for consts + * + * @param string $method Request method + * @return \Elastica\Request Current object + */ + public function setMethod($method) + { + return $this->setParam('method', $method); + } + + /** + * Get request method + * + * @return string Request method + */ + public function getMethod() + { + return $this->getParam('method'); + } + + /** + * Sets the request data + * + * @param array $data Request data + * @return \Elastica\Request + */ + public function setData($data) + { + return $this->setParam('data', $data); + } + + /** + * Return request data + * + * @return array Request data + */ + public function getData() + { + return $this->getParam('data'); + } + + /** + * Sets the request path + * + * @param string $path Request path + * @return \Elastica\Request Current object + */ + public function setPath($path) + { + return $this->setParam('path', $path); + } + + /** + * Return request path + * + * @return string Request path + */ + public function getPath() + { + return $this->getParam('path'); + } + + /** + * Return query params + * + * @return array Query params + */ + public function getQuery() + { + return $this->getParam('query'); + } + + /** + * @param array $query + * @return \Elastica\Request + */ + public function setQuery(array $query = array()) + { + return $this->setParam('query', $query); + } + + /** + * @param \Elastica\Connection $connection + * @return \Elastica\Request + */ + public function setConnection(Connection $connection) + { + $this->_connection = $connection; + + return $this; + } + + /** + * Return Connection Object + * + * @throws Exception\InvalidException + * @return \Elastica\Connection + */ + public function getConnection() + { + if (empty($this->_connection)) { + throw new InvalidException('No valid connection object set'); + } + + return $this->_connection; + } + + /** + * Sends request to server + * + * @return \Elastica\Response Response object + */ + public function send() + { + $transport = $this->getConnection()->getTransportObject(); + + // Refactor: Not full toArray needed in exec? + return $transport->exec($this, $this->getConnection()->toArray()); + } + + /** + * @return array + */ + public function toArray() + { + $data = $this->getParams(); + if ($this->_connection) { + $data['connection'] = $this->_connection->getParams(); + } + return $data; + } + + /** + * Converts request to curl request format + * + * @return string + */ + public function toString() + { + return JSON::stringify($this->toArray()); + } + + /** + * @return string + */ + public function __toString() + { + return $this->toString(); + } +} -- cgit v1.2.3-54-g00ecf