function entity_load in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/includes/entity.inc \entity_load()
Loads an entity from the database.
\Drupal::entityManager()
->getStorage($entity_type)
->load($id);
Parameters
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.
Return value
\Drupal\Core\Entity\EntityInterface|null The entity object, or NULL if there is no entity with the given ID.
Deprecated
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:
See also
\Drupal\Core\Entity\EntityInterface::load()
\Drupal\Core\Entity\EntityManagerInterface::getStorage()
\Drupal\Core\Entity\EntityStorageInterface::load()
\Drupal\Core\Entity\Sql\SqlContentEntityStorage
\Drupal\Core\Entity\Query\QueryInterface
150 calls to entity_load()
- ActionUninstallTest::testActionUninstall in core/
modules/ action/ src/ Tests/ ActionUninstallTest.php - Tests Action uninstall.
- AggregatorRenderingTest::testFeedPage in core/
modules/ aggregator/ src/ Tests/ AggregatorRenderingTest.php - Creates a feed and checks that feed's page.
- BlockContentTranslationUITest::doTestTranslationEdit in core/
modules/ block_content/ src/ Tests/ BlockContentTranslationUITest.php - Tests edit content translation.
- BlockViewBuilder::lazyBuilder in core/
modules/ block/ src/ BlockViewBuilder.php - #lazy_builder callback; builds a #pre_render-able block.
- BooleanFieldTest::testBooleanField in core/
modules/ field/ src/ Tests/ Boolean/ BooleanFieldTest.php - Tests boolean field.
1 string reference to 'entity_load'
- SqlContentEntityStorageTest::setUpModuleHandlerNoImplementations in core/
tests/ Drupal/ Tests/ Core/ Entity/ Sql/ SqlContentEntityStorageTest.php - Sets up the module handler with no implementations.
File
- core/
includes/ entity.inc, line 77 - Entity API for handling entities like nodes or users.
Code
function entity_load($entity_type, $id, $reset = FALSE) {
$controller = \Drupal::entityManager()
->getStorage($entity_type);
if ($reset) {
$controller
->resetCache(array(
$id,
));
}
return $controller
->load($id);
}