Load entity dynamicly by entity type on Drupal 8 | Drupal 8

Load entity dynamicly by entity type on Drupal 8

Submitted by editor on Fri, 02/10/2017 - 11:44
Question

How to load drupal 8 entity dynamicly by entity type and entity id ?

Using entity_load function.

Example:
$entity = entity_load($entity_type, $id);

Using Entity Manager

Example:
$entity = \Drupal::entityTypeManager()->getStorage($entity_type)->load($id);

Add new comment