ConditionInterface.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace Drupal\Core\Entity\Query;
  3. /**
  4. * Defines the entity query condition interface.
  5. */
  6. interface ConditionInterface {
  7. /**
  8. * Gets the current conjunction.
  9. *
  10. * @return string
  11. * Can be AND or OR.
  12. */
  13. public function getConjunction();
  14. /**
  15. * Implements \Countable::count().
  16. *
  17. * Returns the size of this conditional. The size of the conditional is the
  18. * size of its conditional array minus one, because one element is the
  19. * conjunction.
  20. */
  21. public function count();
  22. /**
  23. * Adds a condition.
  24. *
  25. * @param string|\Drupal\Core\Entity\Query\ConditionInterface $field
  26. * @param mixed $value
  27. * @param string $operator
  28. * @param string $langcode
  29. * @return ConditionInterface
  30. * @see \Drupal\Core\Entity\Query\QueryInterface::condition()
  31. */
  32. public function condition($field, $value = NULL, $operator = NULL, $langcode = NULL);
  33. /**
  34. * Queries for the existence of a field.
  35. *
  36. * @param $field
  37. * @param string $langcode
  38. * @return ConditionInterface
  39. * @see \Drupal\Core\Entity\Query\QueryInterface::exists()
  40. */
  41. public function exists($field, $langcode = NULL);
  42. /**
  43. * Queries for the existence of a field.
  44. *
  45. * @param string $field
  46. * @return ConditionInterface
  47. * @see \Drupal\Core\Entity\Query\QueryInterface::notExists()
  48. */
  49. public function notExists($field, $langcode = NULL);
  50. /**
  51. * Gets a complete list of all conditions in this conditional clause.
  52. *
  53. * This method returns by reference. That allows alter hooks to access the
  54. * data structure directly and manipulate it before it gets compiled.
  55. *
  56. * @return array
  57. */
  58. public function &conditions();
  59. /**
  60. * Compiles this conditional clause.
  61. *
  62. * @param $query
  63. * The query object this conditional clause belongs to.
  64. */
  65. public function compile($query);
  66. }