function Tables::__construct

Same name in this branch
  1. 9 core/lib/Drupal/Core/Entity/Query/Sql/Tables.php \Drupal\Core\Entity\Query\Sql\Tables::__construct()
Same name in other branches
  1. 8.9.x core/modules/workspaces/src/EntityQuery/Tables.php \Drupal\workspaces\EntityQuery\Tables::__construct()
  2. 8.9.x core/lib/Drupal/Core/Entity/Query/Sql/Tables.php \Drupal\Core\Entity\Query\Sql\Tables::__construct()
  3. 10 core/modules/workspaces/src/EntityQuery/Tables.php \Drupal\workspaces\EntityQuery\Tables::__construct()
  4. 10 core/lib/Drupal/Core/Entity/Query/Sql/Tables.php \Drupal\Core\Entity\Query\Sql\Tables::__construct()
  5. 11.x core/modules/workspaces/src/EntityQuery/Tables.php \Drupal\workspaces\EntityQuery\Tables::__construct()
  6. 11.x core/lib/Drupal/Core/Entity/Query/Sql/Tables.php \Drupal\Core\Entity\Query\Sql\Tables::__construct()

Overrides Tables::__construct

File

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

Class

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

Namespace

Drupal\workspaces\EntityQuery

Code

public function __construct(SelectInterface $sql_query) {
    parent::__construct($sql_query);
    $this->workspaceManager = \Drupal::service('workspaces.manager');
    // The join between the first 'workspace_association' table and base table
    // of the query is done in
    // \Drupal\workspaces\EntityQuery\QueryTrait::prepare(), so we need to
    // initialize its entry manually.
    if ($this->sqlQuery
        ->getMetaData('active_workspace_id')) {
        $this->contentWorkspaceTables['base_table'] = 'workspace_association';
        $this->baseTablesEntityType['base_table'] = $this->sqlQuery
            ->getMetaData('entity_type');
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.