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

Breadcrumb

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

function Tables::addField

Same name in this branch
  1. 11.1.x core/lib/Drupal/Core/Entity/Query/Sql/Tables.php \Drupal\Core\Entity\Query\Sql\Tables::addField()

Overrides Tables::addField

File

core/modules/workspaces/src/EntityQuery/Tables.php, line 61

Class

Tables
Alters entity queries to use a workspace revision instead of the default one.

Namespace

Drupal\workspaces\EntityQuery

Code

public function addField($field, $type, $langcode) {
    // The parent method uses shared and dedicated revision tables only when the
    // entity query is instructed to query all revisions. However, if we are
    // looking for workspace-specific revisions, we have to force the parent
    // method to always pick the revision tables if the field being queried is
    // revisionable.
    if ($this->sqlQuery
        ->getMetaData('active_workspace_id')) {
        $previous_all_revisions = $this->sqlQuery
            ->getMetaData('all_revisions');
        $this->sqlQuery
            ->addMetaData('all_revisions', TRUE);
    }
    $alias = parent::addField($field, $type, $langcode);
    // Restore the 'all_revisions' metadata because we don't want to interfere
    // with the rest of the query.
    if (isset($previous_all_revisions)) {
        $this->sqlQuery
            ->addMetaData('all_revisions', $previous_all_revisions);
    }
    return $alias;
}

API Navigation

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