entity_load($entity_type,$id, $reset = FALSE)
Loads an entity from the database.
\Drupal::entityTypeManager()->getStorage($entity_type)->load($id);
string $entity_type: The entity type to load, e.g. node or user.
mixed $id: The id of the entity to load.
bool $reset: Whether to reset the internal cache for the requested entity type.
\Drupal\Core\Entity\EntityInterface|null The entity object, or NULL if there is no entity with the given ID.
in Drupal 8.0.x, will be removed before Drupal 9.0.0. Use The method overriding Entity::load() for the entity type, e.g. \Drupal\node\Entity\Node::load() if the entity type is known. If the entity type is variable, use the entity manager service to load the entity from the entity storage:
\Drupal\Core\Entity\EntityInterface::load()
\Drupal\Core\Entity\EntityTypeManagerInterface::getStorage()
\Drupal\Core\Entity\EntityStorageInterface::load()
\Drupal\Core\Entity\Sql\SqlContentEntityStorage
\Drupal\Core\Entity\Query\QueryInterface
function entity_load($entity_type, $id, $reset = FALSE) { $controller = \Drupal::entityManager()->getStorage($entity_type); if ($reset) { $controller->resetCache(array($id)); } return $controller->load($id); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!includes!entity.inc/function/entity_load/8.1.x