function ViewsData::getViewsData
Same name in other branches
- 9 core/modules/content_moderation/src/ViewsData.php \Drupal\content_moderation\ViewsData::getViewsData()
- 8.9.x core/modules/content_moderation/src/ViewsData.php \Drupal\content_moderation\ViewsData::getViewsData()
- 11.x core/modules/content_moderation/src/ViewsData.php \Drupal\content_moderation\ViewsData::getViewsData()
Returns the views data.
Return value
array The views data.
File
-
core/
modules/ content_moderation/ src/ ViewsData.php, line 51
Class
- ViewsData
- Provides the content_moderation views integration.
Namespace
Drupal\content_moderationCode
public function getViewsData() {
$data = [];
$entity_types_with_moderation = array_filter($this->entityTypeManager
->getDefinitions(), function (EntityTypeInterface $type) {
return $this->moderationInformation
->isModeratedEntityType($type);
});
foreach ($entity_types_with_moderation as $entity_type) {
$table = $entity_type->getDataTable() ?: $entity_type->getBaseTable();
$data[$table]['moderation_state'] = [
'title' => t('Moderation state'),
'field' => [
'id' => 'moderation_state_field',
'default_formatter' => 'content_moderation_state',
'field_name' => 'moderation_state',
],
'filter' => [
'id' => 'moderation_state_filter',
'allow empty' => TRUE,
],
'sort' => [
'id' => 'moderation_state_sort',
],
];
$revision_table = $entity_type->getRevisionDataTable() ?: $entity_type->getRevisionTable();
$data[$revision_table]['moderation_state'] = [
'title' => t('Moderation state'),
'field' => [
'id' => 'moderation_state_field',
'default_formatter' => 'content_moderation_state',
'field_name' => 'moderation_state',
],
'filter' => [
'id' => 'moderation_state_filter',
'allow empty' => TRUE,
],
'sort' => [
'id' => 'moderation_state_sort',
],
];
}
return $data;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.