function EntityTrait::reloadEntity

Reloads the given entity from the storage and returns it.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to be reloaded.

Return value

\Drupal\Core\Entity\EntityInterface The reloaded entity.

11 calls to EntityTrait::reloadEntity()
ContentEntityCloneTest::testClonedEntityFields in core/tests/Drupal/KernelTests/Core/Entity/ContentEntityCloneTest.php
Tests if the entity fields are properly cloned.
EntityRevisionTranslationTest::testRevertRevisionAfterTranslation in core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionTranslationTest.php
Tests if the translation object has the right revision id after new revision.
EntityRevisionTranslationTest::testTranslationValuesWhenSavingPendingRevisions in core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionTranslationTest.php
Tests the translation values when saving a pending revision.
EntityTranslationTest::doTestEntityTranslationAPI in core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php
Executes the Entity Translation API tests for the given entity type.
EntityTranslationTest::doTestLanguageFallback in core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php
Executes the language fallback test for the given entity type.

... See full list

File

core/tests/Drupal/Tests/EntityTrait.php, line 32

Class

EntityTrait
Provides helper methods for working with entities in tests.

Namespace

Drupal\Tests

Code

protected function reloadEntity(EntityInterface $entity) : EntityInterface {
    $controller = $this->entityTypeManager
        ->getStorage($entity->getEntityTypeId());
    $controller->resetCache([
        $entity->id(),
    ]);
    return $controller->load($entity->id());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.