You are here

protected function SelectionBase::reAlterQuery in Entity reference 8

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 SelectionBase::reAlterQuery()
SelectionEntityTypeComment::entityFieldQueryAlter in lib/Drupal/entityreference/Plugin/Type/Selection/SelectionEntityTypeComment.php
Implements EntityReferenceHandler::entityFieldQueryAlter().
SelectionEntityTypeTaxonomyTerm::entityFieldQueryAlter in lib/Drupal/entityreference/Plugin/Type/Selection/SelectionEntityTypeTaxonomyTerm.php
Implements EntityReferenceHandler::entityFieldQueryAlter().

File

lib/Drupal/entityreference/Plugin/entityreference/selection/SelectionBase.php, line 287
Definition of Drupal\entityreference\Plugin\entityreference\selection\SelectionBase.

Class

SelectionBase
Plugin implementation of the 'selection' entityreference.

Namespace

Drupal\entityreference\Plugin\entityreference\selection

Code

protected function reAlterQuery(AlterableInterface $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;
}