3 namespace Drupal\Core\Database\Query;
6 * Interface for a query that can be manipulated via an alter hook.
8 interface AlterableInterface {
11 * Adds a tag to a query.
13 * Tags are strings that identify a query. A query may have any number of
14 * tags. Tags are used to mark a query so that alter hooks may decide if they
15 * wish to take action. Tags should be all lower-case and contain only
16 * letters, numbers, and underscore, and start with a letter. That is, they
17 * should follow the same rules as PHP identifiers in general.
22 * @return \Drupal\Core\Database\Query\AlterableInterface
25 public function addTag($tag);
28 * Determines if a given query has a given tag.
34 * TRUE if this query has been marked with this tag, FALSE otherwise.
36 public function hasTag($tag);
39 * Determines if a given query has all specified tags.
42 * A variable number of arguments, one for each tag to check.
45 * TRUE if this query has been marked with all specified tags, FALSE
48 public function hasAllTags();
51 * Determines if a given query has any specified tag.
54 * A variable number of arguments, one for each tag to check.
57 * TRUE if this query has been marked with at least one of the specified
58 * tags, FALSE otherwise.
60 public function hasAnyTag();
63 * Adds additional metadata to the query.
65 * Often, a query may need to provide additional contextual data to alter
66 * hooks. Alter hooks may then use that information to decide if and how
70 * The unique identifier for this piece of metadata. Must be a string that
71 * follows the same rules as any other PHP identifier.
73 * The additional data to add to the query. May be any valid PHP variable.
75 * @return \Drupal\Core\Database\Query\AlterableInterface
78 public function addMetaData($key, $object);
81 * Retrieves a given piece of metadata.
84 * The unique identifier for the piece of metadata to retrieve.
87 * The previously attached metadata object, or NULL if one doesn't exist.
89 public function getMetaData($key);