public function LatestTranslationAffectedRevision::query in Drupal 8
Same name and namespace in other branches
- 9 core/modules/views/src/Plugin/views/filter/LatestTranslationAffectedRevision.php \Drupal\views\Plugin\views\filter\LatestTranslationAffectedRevision::query()
- 10 core/modules/views/src/Plugin/views/filter/LatestTranslationAffectedRevision.php \Drupal\views\Plugin\views\filter\LatestTranslationAffectedRevision::query()
Add this filter to the query.
Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.
Overrides FilterPluginBase::query
File
- core/
modules/ views/ src/ Plugin/ views/ filter/ LatestTranslationAffectedRevision.php, line 88
Class
- LatestTranslationAffectedRevision
- Filter to show only the latest translation affected revision of an entity.
Namespace
Drupal\views\Plugin\views\filterCode
public function query() {
/** @var \Drupal\views\Plugin\views\query\Sql $query */
$query = $this->query;
$query_base_table = $this->relationship ?: $this->view->storage
->get('base_table');
$entity_type = $this->entityTypeManager
->getDefinition($this
->getEntityType());
$keys = $entity_type
->getKeys();
$definition = [
'table' => $query_base_table,
'type' => 'LEFT',
'field' => $keys['id'],
'left_table' => $query_base_table,
'left_field' => $keys['id'],
'extra' => [
[
'left_field' => $keys['revision'],
'field' => $keys['revision'],
'operator' => '>',
],
[
'left_field' => 'langcode',
'field' => 'langcode',
'operator' => '=',
],
[
'field' => 'revision_translation_affected',
'value' => '1',
'operator' => '=',
],
],
];
$join = $this->joinHandler
->createInstance('standard', $definition);
$join_table_alias = $query
->addTable($query_base_table, $this->relationship, $join);
$query
->addWhere($this->options['group'], "{$join_table_alias}.{$keys['id']}", NULL, 'IS NULL');
$query
->addWhere($this->options['group'], "{$query_base_table}.revision_translation_affected", '1', '=');
}