AlterableInterface.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace Drupal\Core\Database\Query;
  3. /**
  4. * Interface for a query that can be manipulated via an alter hook.
  5. */
  6. interface AlterableInterface {
  7. /**
  8. * Adds a tag to a query.
  9. *
  10. * Tags are strings that identify a query. A query may have any number of
  11. * tags. Tags are used to mark a query so that alter hooks may decide if they
  12. * wish to take action. Tags should be all lower-case and contain only
  13. * letters, numbers, and underscore, and start with a letter. That is, they
  14. * should follow the same rules as PHP identifiers in general.
  15. *
  16. * @param $tag
  17. * The tag to add.
  18. *
  19. * @return \Drupal\Core\Database\Query\AlterableInterface
  20. * The called object.
  21. */
  22. public function addTag($tag);
  23. /**
  24. * Determines if a given query has a given tag.
  25. *
  26. * @param $tag
  27. * The tag to check.
  28. *
  29. * @return
  30. * TRUE if this query has been marked with this tag, FALSE otherwise.
  31. */
  32. public function hasTag($tag);
  33. /**
  34. * Determines if a given query has all specified tags.
  35. *
  36. * @param $tags
  37. * A variable number of arguments, one for each tag to check.
  38. *
  39. * @return
  40. * TRUE if this query has been marked with all specified tags, FALSE
  41. * otherwise.
  42. */
  43. public function hasAllTags();
  44. /**
  45. * Determines if a given query has any specified tag.
  46. *
  47. * @param $tags
  48. * A variable number of arguments, one for each tag to check.
  49. *
  50. * @return
  51. * TRUE if this query has been marked with at least one of the specified
  52. * tags, FALSE otherwise.
  53. */
  54. public function hasAnyTag();
  55. /**
  56. * Adds additional metadata to the query.
  57. *
  58. * Often, a query may need to provide additional contextual data to alter
  59. * hooks. Alter hooks may then use that information to decide if and how
  60. * to take action.
  61. *
  62. * @param $key
  63. * The unique identifier for this piece of metadata. Must be a string that
  64. * follows the same rules as any other PHP identifier.
  65. * @param $object
  66. * The additional data to add to the query. May be any valid PHP variable.
  67. *
  68. * @return \Drupal\Core\Database\Query\AlterableInterface
  69. * The called object.
  70. */
  71. public function addMetaData($key, $object);
  72. /**
  73. * Retrieves a given piece of metadata.
  74. *
  75. * @param $key
  76. * The unique identifier for the piece of metadata to retrieve.
  77. *
  78. * @return
  79. * The previously attached metadata object, or NULL if one doesn't exist.
  80. */
  81. public function getMetaData($key);
  82. }