public function RelationshipPluginBase::query in Views (for Drupal 7) 8.3
Called to implement a relationship in a query.
Overrides PluginBase::query
5 methods override RelationshipPluginBase::query()
- Broken::query in lib/
Drupal/ views/ Plugin/ views/ relationship/ Broken.php - Called to implement a relationship in a query.
- EntityReverse::query in lib/
Views/ field/ Plugin/ views/ relationship/ EntityReverse.php - Called to implement a relationship in a query.
- GroupwiseMax::query in lib/
Drupal/ views/ Plugin/ views/ relationship/ GroupwiseMax.php - Called to implement a relationship in a query. This is mostly a copy of our parent's query() except for this bit with the join class.
- NodeTermData::query in lib/
Views/ taxonomy/ Plugin/ views/ relationship/ NodeTermData.php - Called to implement a relationship in a query.
- Translation::query in lib/
Views/ translation/ Plugin/ views/ relationship/ Translation.php - Called to implement a relationship in a query.
File
- lib/
Drupal/ views/ Plugin/ views/ relationship/ RelationshipPluginBase.php, line 117 - Definition of Drupal\views\Plugin\views\relationship\RelationshipPluginBase.
Class
- RelationshipPluginBase
- Simple relationship handler that allows a new version of the primary table to be linked in.
Namespace
Drupal\views\Plugin\views\relationshipCode
public function query() {
// Figure out what base table this relationship brings to the party.
$table_data = views_fetch_data($this->definition['base']);
$base_field = empty($this->definition['base field']) ? $table_data['table']['base']['field'] : $this->definition['base field'];
$this
->ensureMyTable();
$def = $this->definition;
$def['table'] = $this->definition['base'];
$def['field'] = $base_field;
$def['left_table'] = $this->tableAlias;
$def['left_field'] = $this->realField;
$def['adjusted'] = TRUE;
if (!empty($this->options['required'])) {
$def['type'] = 'INNER';
}
if (!empty($this->definition['extra'])) {
$def['extra'] = $this->definition['extra'];
}
if (!empty($def['join_id'])) {
$id = $def['join_id'];
}
else {
$id = 'standard';
}
$join = drupal_container()
->get('plugin.manager.views.join')
->createInstance($id, $def);
// use a short alias for this:
$alias = $def['table'] . '_' . $this->table;
$this->alias = $this->query
->add_relationship($alias, $join, $this->definition['base'], $this->relationship);
// Add access tags if the base table provide it.
if (empty($this->query->options['disable_sql_rewrite']) && isset($table_data['table']['base']['access query tag'])) {
$access_tag = $table_data['table']['base']['access query tag'];
$this->query
->add_tag($access_tag);
}
}