Simple.php 962 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace Elastica\Query;
  3. /**
  4. * Simple query
  5. * Pure php array query. Can be used to create any not existing type of query.
  6. *
  7. * @author Nicolas Ruflin <spam@ruflin.com>
  8. */
  9. class Simple extends AbstractQuery
  10. {
  11. /**
  12. * Query.
  13. *
  14. * @var array Query
  15. */
  16. protected $_query = [];
  17. /**
  18. * Constructs a query based on an array.
  19. *
  20. * @param array $query Query array
  21. */
  22. public function __construct(array $query)
  23. {
  24. $this->setQuery($query);
  25. }
  26. /**
  27. * Sets new query array.
  28. *
  29. * @param array $query Query array
  30. *
  31. * @return $this
  32. */
  33. public function setQuery(array $query)
  34. {
  35. $this->_query = $query;
  36. return $this;
  37. }
  38. /**
  39. * Converts query to array.
  40. *
  41. * @return array Query array
  42. *
  43. * @see \Elastica\Query\AbstractQuery::toArray()
  44. */
  45. public function toArray()
  46. {
  47. return $this->_query;
  48. }
  49. }