What I'm trying to do is

$entities = EntityInterface::loadMultiple();

That should give me all entities.

But when I call it, it gives me this

Fatal error: Cannot call abstract method Drupal\Core\Entity\EntityInterface::loadMultiple()

What I need is the type and the bundles of the entities.

I don't want to get specific entities like Node, Comment, Block etc. I want to get them all.

$fields['node']['article'] =  <<<< I want that dynamic.

Something like that

foreach($entities as $entity) {
  $fields[$entity->getType()][$entity->bundle()] = ....

1 Answer 1


You can get around the error about the abstract method by using entity::loadMultiple, but you'll get a new error, because this only works from an entity subclass.

Instead of using the static method, you would have to do this dynamically:

First get all content entity types:

  $entity_types = \Drupal::entityTypeManager()->getDefinitions();
  $content_entity_types = array_filter($entity_types, function ($entity_type) {
    return $entity_type instanceof \Drupal\Core\Entity\ContentEntityTypeInterface;
  $content_entity_type_ids = array_keys($content_entity_types);

Then load all entities for each type:

  $entities = [];
  foreach ($content_entity_type_ids as $type) {
    $entities[$type] = \Drupal::entityTypeManager()->getStorage($type)->loadMultiple();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.