/Drupal 8

function hook_entity_query_alter

hook_entity_query_alter(\Drupal\Core\Entity\Query\QueryInterface $query)

Alter or execute an Drupal\Core\Entity\Query\EntityQueryInterface.


\Drupal\Core\Entity\Query\QueryInterface $query: Note the $query->altered attribute which is TRUE in case the query has already been altered once. This happens with cloned queries. If there is a pager, then such a cloned query will be executed to count all elements. This query can be detected by checking for ($query->pager && $query->count), allowing the driver to return 0 from the count query and disable the pager.

Related topics

Define functions that alter the behavior of Drupal core.


core/lib/Drupal/Core/Entity/entity.api.php, line 1266
Hooks and documentation related to entities.


function hook_entity_query_alter(\Drupal\Core\Entity\Query\QueryInterface $query) {
  // @todo: code example.

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.