protected function SelectionBase::reAlterQuery

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

This allows Entity Reference to add a tag to an existing query so it can ask access control mechanisms to alter it again.

1 call to SelectionBase::reAlterQuery()
CommentSelection::entityQueryAlter in drupal/core/modules/comment/lib/Drupal/comment/Plugin/entity_reference/selection/CommentSelection.php
Overrides SelectionBase::entityQueryAlter().

File

drupal/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/SelectionBase.php, line 310
Contains \Drupal\entity_reference\Plugin\entity_reference\selection\SelectionBase.

Class

SelectionBase
Plugin implementation of the 'selection' entity_reference.

Namespace

Drupal\entity_reference\Plugin\entity_reference\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;
}