diff --git a/core/lib/Drupal/Core/Entity/Query/QueryBase.php b/core/lib/Drupal/Core/Entity/Query/QueryBase.php index 9ad26e1..3ae7866 100644 --- a/core/lib/Drupal/Core/Entity/Query/QueryBase.php +++ b/core/lib/Drupal/Core/Entity/Query/QueryBase.php @@ -239,4 +239,48 @@ public function tableSort(&$headers) { function __clone() { $this->condition = clone $this->condition; } + + /** + * Implements Drupal\Core\Entity\Query\QueryInterface::addTag(). + */ + public function addTag($tag) { + $this->alterTags[$tag] = 1; + return $this; + } + + /** + * Implements Drupal\Core\Entity\Query\QueryInterface::hasTag(). + */ + public function hasTag($tag) { + return isset($this->alterTags[$tag]); + } + + /** + * Implements Drupal\Core\Entity\Query\QueryInterface::hasAllTags(). + */ + public function hasAllTags() { + return !(boolean)array_diff(func_get_args(), array_keys($this->alterTags)); + } + + /** + * Implements Drupal\Core\Entity\Query\QueryInterface::hasAnyTag(). + */ + public function hasAnyTag() { + return (boolean)array_intersect(func_get_args(), array_keys($this->alterTags)); + } + + /** + * Implements Drupal\Core\Entity\Query\QueryInterface::addMetaData(). + */ + public function addMetaData($key, $object) { + $this->alterMetaData[$key] = $object; + return $this; + } + + /** + * Implements Drupal\Core\Entity\Query\QueryInterface::getMetaData(). + */ + public function getMetaData($key) { + return isset($this->alterMetaData[$key]) ? $this->alterMetaData[$key] : NULL; + } } diff --git a/core/lib/Drupal/Core/Entity/Query/QueryInterface.php b/core/lib/Drupal/Core/Entity/Query/QueryInterface.php index 477de7d..ec9627e 100644 --- a/core/lib/Drupal/Core/Entity/Query/QueryInterface.php +++ b/core/lib/Drupal/Core/Entity/Query/QueryInterface.php @@ -7,13 +7,15 @@ namespace Drupal\Core\Entity\Query; +use Drupal\Core\Database\Query\AlterableInterface; + /** * Interface for entity queries. * * Never instantiate classes implementing this interface directly. Always use * the QueryFactory class. */ -interface QueryInterface { +interface QueryInterface extends AlterableInterface { /** * Gets the entity type for this query. diff --git a/core/modules/field/modules/field_sql_storage/lib/Drupal/field_sql_storage/Entity/Query.php b/core/modules/field/modules/field_sql_storage/lib/Drupal/field_sql_storage/Entity/Query.php index 44023ce..b8d9f3a 100644 --- a/core/modules/field/modules/field_sql_storage/lib/Drupal/field_sql_storage/Entity/Query.php +++ b/core/modules/field/modules/field_sql_storage/lib/Drupal/field_sql_storage/Entity/Query.php @@ -100,6 +100,13 @@ public function execute() { } $sqlQuery->addTag('entity_query'); $sqlQuery->addTag('entity_query_' . $this->entityType); + + // Add further tags added. + if (isset($this->alterTags)) { + foreach ($this->alterTags as $tag => $value) { + $sqlQuery->addTag($tag); + } + } // This now contains first the table containing entity properties and // last the entity base table. They might be the same. $sqlQuery->addMetaData('entity_tables', $entity_tables);