ViewsData::alterViewsData

public ViewsData::alterViewsData(array &$data)

Alters the table and field information from hook_views_data().

Parameters

array $data: An array of all information about Views tables and fields, collected from hook_views_data(), passed by reference.

See also

hook_views_data()

File

core/modules/content_moderation/src/ViewsData.php, line 240

Class

ViewsData
Provides the content_moderation views integration.

Namespace

Drupal\content_moderation

Code

public function alterViewsData(array &$data) {
  $entity_types_with_moderation = array_filter($this->entityTypeManager->getDefinitions(), function(EntityTypeInterface $type) {
    return $this->moderationInformation->canModerateEntitiesOfEntityType($type);
  });
  foreach ($entity_types_with_moderation as $type) {
    $data[$type->getRevisionTable()]['latest_revision'] = [
      'title' => t('Is Latest Revision'),
      'help' => t('Restrict the view to only revisions that are the latest revision of their entity.'),
      'filter' => ['id' => 'latest_revision'],
    ];
  }
}
doc_Drupal
2016-10-29 09:54:58
Comments
Leave a Comment

Please login to continue.