You are here

protected function EntityReference_SelectionHandler_Generic::reAlterQuery in Entity reference 7

Helper method: pass a query to the alteration system again.

This allow Entity Reference to add a tag to an existing query, to ask access control mechanisms to alter it again.

2 calls to EntityReference_SelectionHandler_Generic::reAlterQuery()
EntityReference_SelectionHandler_Generic_comment::entityFieldQueryAlter in plugins/selection/EntityReference_SelectionHandler_Generic.class.php
Implements EntityReferenceHandler::entityFieldQueryAlter().
EntityReference_SelectionHandler_Generic_taxonomy_term::entityFieldQueryAlter in plugins/selection/EntityReference_SelectionHandler_Generic.class.php
Implements EntityReferenceHandler::entityFieldQueryAlter().

File

plugins/selection/EntityReference_SelectionHandler_Generic.class.php, line 292

Class

EntityReference_SelectionHandler_Generic
A generic Entity handler.

Code

protected function reAlterQuery(SelectQueryInterface $query, $tag, $base_table) {

  // Save the old tags and metadata.
  // For some reason, those are public.
  $old_tags = $query->alterTags;
  $old_metadata = $query->alterMetaData;
  $query->alterTags = array(
    $tag => TRUE,
  );
  $query->alterMetaData['base_table'] = $base_table;
  drupal_alter(array(
    'query',
    'query_' . $tag,
  ), $query);

  // Restore the tags and metadata.
  $query->alterTags = $old_tags;
  $query->alterMetaData = $old_metadata;
}