Drupal investigation

entity.views.inc 909B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. use Drupal\Core\Entity\ContentEntityInterface;
  3. use Drupal\Core\Entity\EntityTypeInterface;
  4. /**
  5. * Implements hook_views_data().
  6. */
  7. function entity_views_data() {
  8. $entity_types = \Drupal::entityTypeManager()->getDefinitions();
  9. $entity_types = array_filter($entity_types, function (EntityTypeInterface $entity_type) {
  10. return $entity_type->isSubclassOf(ContentEntityInterface::class);
  11. });
  12. $data = [];
  13. foreach ($entity_types as $entity_type) {
  14. /** @var \Drupal\Core\Entity\EntityTypeInterface $entity_type */
  15. $base_table = $entity_type->getBaseTable() ?: $entity_type->id();
  16. if ($entity_type->hasViewBuilderClass()) {
  17. $data[$base_table]['rendered_entity'] = [
  18. 'field' => [
  19. 'title' => t('Rendered entity'),
  20. 'help' => t('Renders an entity in a view mode.'),
  21. 'id' => 'rendered_entity',
  22. ],
  23. ];
  24. }
  25. }
  26. return $data;
  27. }