function LatestTranslationAffectedRevision::query
Same name in other branches
- 8.9.x 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()
- 11.x core/modules/views/src/Plugin/views/filter/LatestTranslationAffectedRevision.php \Drupal\views\Plugin\views\filter\LatestTranslationAffectedRevision::query()
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', '=');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.