public function Translation::query in Views (for Drupal 7) 8.3
Called to implement a relationship in a query.
Overrides RelationshipPluginBase::query
File
- lib/
Views/ translation/ Plugin/ views/ relationship/ Translation.php, line 57 - Definition of Views\translation\Plugin\views\relationship\Translation.
Class
- Translation
- Handles relationships for content translation sets and provides multiple options.
Namespace
Views\translation\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->field;
$def['adjusted'] = TRUE;
if (!empty($this->options['required'])) {
$def['type'] = 'INNER';
}
$def['extra'] = array();
if ($this->options['language'] != 'all') {
switch ($this->options['language']) {
case 'current':
$def['extra'][] = array(
'field' => 'langcode',
'value' => '***CURRENT_LANGUAGE***',
);
break;
case 'default':
$def['extra'][] = array(
'field' => 'langcode',
'value' => '***DEFAULT_LANGUAGE***',
);
break;
// Other values will be the language codes.
default:
$def['extra'][] = array(
'field' => 'langcode',
'value' => $this->options['language'],
);
break;
}
}
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);
}