You are here

protected function RelationStorage::buildQuery in Relation 8

Same name and namespace in other branches
  1. 8.2 src/RelationStorage.php \Drupal\relation\RelationStorage::buildQuery()

Builds the query to load the entity.

This has full revision support. For entities requiring special queries, the class can be extended, and the default query can be constructed by calling parent::buildQuery(). This is usually necessary when the object being loaded needs to be augmented with additional data from another table, such as loading vocabulary machine name into terms, however it can also support $conditions on different tables.

Parameters

array|null $ids: An array of entity IDs, or NULL to load all entities.

array|bool $revision_ids: The IDs of the revisions to load, or FALSE if this query is asking for the default revisions. Defaults to FALSE.

Return value

\Drupal\Core\Database\Query\SelectInterface A SelectQuery object for loading the entity.

Overrides SqlContentEntityStorage::buildQuery

File

src/RelationStorage.php, line 35
Contains \Drupal\relation\RelationStorage.

Class

RelationStorage
Relation controller class.

Namespace

Drupal\relation

Code

protected function buildQuery($ids, $revision_id = FALSE) {

  // Ensure that uid is taken from the {relation} table.
  $query = parent::buildQuery($ids, $revision_id);
  $fields =& $query
    ->getFields();
  $fields['uid']['table'] = 'base';
  $query
    ->addField('revision', 'uid', 'revision_uid');
  $fields['changed']['table'] = 'base';
  $query
    ->addField('revision', 'changed', 'changed');
  return $query;
}