3 use Drupal\Core\Entity\ContentEntityInterface;
4 use Drupal\Core\Entity\EntityTypeInterface;
7 * Implements hook_views_data().
9 function entity_views_data() {
10 $entity_types = \Drupal::entityTypeManager()->getDefinitions();
11 $entity_types = array_filter($entity_types, function (EntityTypeInterface $entity_type) {
12 return $entity_type->entityClassImplements(ContentEntityInterface::class);
16 foreach ($entity_types as $entity_type) {
17 /** @var \Drupal\Core\Entity\EntityTypeInterface $entity_type */
18 $base_table = $entity_type->getBaseTable() ?: $entity_type->id();
20 if ($entity_type->hasViewBuilderClass()) {
21 $data[$base_table]['rendered_entity'] = [
23 'title' => t('Rendered entity'),
24 'help' => t('Renders an entity in a view mode.'),
25 'id' => 'rendered_entity',