function EntityFormTest::loadEntityByName
Same name in other branches
- 9 core/modules/system/tests/src/Functional/Entity/EntityFormTest.php \Drupal\Tests\system\Functional\Entity\EntityFormTest::loadEntityByName()
- 8.9.x core/modules/system/tests/src/Functional/Entity/EntityFormTest.php \Drupal\Tests\system\Functional\Entity\EntityFormTest::loadEntityByName()
- 11.x core/modules/system/tests/src/Functional/Entity/EntityFormTest.php \Drupal\Tests\system\Functional\Entity\EntityFormTest::loadEntityByName()
Loads a test entity by name always resetting the storage cache.
2 calls to EntityFormTest::loadEntityByName()
- EntityFormTest::doTestFormCRUD in core/
modules/ system/ tests/ src/ Functional/ Entity/ EntityFormTest.php - Executes the form CRUD tests for the given entity type.
- EntityFormTest::doTestMultilingualFormCRUD in core/
modules/ system/ tests/ src/ Functional/ Entity/ EntityFormTest.php - Executes the multilingual form CRUD tests for the given entity type ID.
File
-
core/
modules/ system/ tests/ src/ Functional/ Entity/ EntityFormTest.php, line 212
Class
- EntityFormTest
- Tests the entity form.
Namespace
Drupal\Tests\system\Functional\EntityCode
protected function loadEntityByName($entity_type, $name) {
// Always load the entity from the database to ensure that changes are
// correctly picked up.
$entity_storage = $this->container
->get('entity_type.manager')
->getStorage($entity_type);
$entity_storage->resetCache();
$entities = $entity_storage->loadByProperties([
'name' => $name,
]);
return $entities ? current($entities) : NULL;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.