Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DefaultSelection.php

function DefaultSelection::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 DefaultSelection::reAlterQuery()
CommentSelection::entityQueryAlter in core/modules/comment/src/Plugin/EntityReferenceSelection/CommentSelection.php
Allows the selection to alter the SelectQuery generated by EntityFieldQuery.

File

core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php, line 519

Class

DefaultSelection
Default plugin implementation of the Entity Reference Selection plugin.

Namespace

Drupal\Core\Entity\Plugin\EntityReferenceSelection

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 = [
        $tag => TRUE,
    ];
    $query->alterMetaData['base_table'] = $base_table;
    $this->moduleHandler
        ->alter([
        'query',
        'query_' . $tag,
    ], $query);
    // Restore the tags and metadata.
    $query->alterTags = $old_tags;
    $query->alterMetaData = $old_metadata;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal