function TermStorage::getTermIdsWithPendingRevisions
Same name in other branches
- 9 core/modules/taxonomy/src/TermStorage.php \Drupal\taxonomy\TermStorage::getTermIdsWithPendingRevisions()
- 8.9.x core/modules/taxonomy/src/TermStorage.php \Drupal\taxonomy\TermStorage::getTermIdsWithPendingRevisions()
- 10 core/modules/taxonomy/src/TermStorage.php \Drupal\taxonomy\TermStorage::getTermIdsWithPendingRevisions()
Overrides TermStorageInterface::getTermIdsWithPendingRevisions
File
-
core/
modules/ taxonomy/ src/ TermStorage.php, line 366
Class
- TermStorage
- Defines a Controller class for taxonomy terms.
Namespace
Drupal\taxonomyCode
public function getTermIdsWithPendingRevisions() {
$table_mapping = $this->getTableMapping();
$id_field = $table_mapping->getColumnNames($this->entityType
->getKey('id'))['value'];
$revision_field = $table_mapping->getColumnNames($this->entityType
->getKey('revision'))['value'];
$rta_field = $table_mapping->getColumnNames($this->entityType
->getKey('revision_translation_affected'))['value'];
$langcode_field = $table_mapping->getColumnNames($this->entityType
->getKey('langcode'))['value'];
$revision_default_field = $table_mapping->getColumnNames($this->entityType
->getRevisionMetadataKey('revision_default'))['value'];
$query = $this->database
->select($this->getRevisionDataTable(), 'tfr');
$query->fields('tfr', [
$id_field,
]);
$query->addExpression("MAX([tfr].[{$revision_field}])", $revision_field);
$query->join($this->getRevisionTable(), 'tr', "[tfr].[{$revision_field}] = [tr].[{$revision_field}] AND [tr].[{$revision_default_field}] = 0");
$inner_select = $this->database
->select($this->getRevisionDataTable(), 't');
$inner_select->condition("t.{$rta_field}", '1');
$inner_select->fields('t', [
$id_field,
$langcode_field,
]);
$inner_select->addExpression("MAX([t].[{$revision_field}])", $revision_field);
$inner_select->groupBy("t.{$id_field}")
->groupBy("t.{$langcode_field}");
$query->join($inner_select, 'mr', "[tfr].[{$revision_field}] = [mr].[{$revision_field}] AND [tfr].[{$langcode_field}] = [mr].[{$langcode_field}]");
$query->groupBy("tfr.{$id_field}");
return $query->execute()
->fetchAllKeyed(1, 0);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.