function ContentModerationStateTest::reloadEntity
Same name and namespace in other branches
- 11.x core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationStateTest::reloadEntity()
- 10 core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationStateTest::reloadEntity()
- 8.9.x core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php \Drupal\Tests\content_moderation\Kernel\ContentModerationStateTest::reloadEntity()
Reloads the entity after clearing the static cache.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity to reload.
int|bool $revision_id: The specific revision ID to load. Defaults FALSE and just loads the default revision.
Return value
\Drupal\Core\Entity\EntityInterface The reloaded entity.
File
-
core/
modules/ content_moderation/ tests/ src/ Kernel/ ContentModerationStateTest.php, line 774
Class
- ContentModerationStateTest
- Tests links between a content entity and a content_moderation_state entity.
Namespace
Drupal\Tests\content_moderation\KernelCode
protected function reloadEntity(EntityInterface $entity, $revision_id = FALSE) {
$storage = \Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId());
$storage->resetCache([
$entity->id(),
]);
if ($revision_id) {
return $storage->loadRevision($revision_id);
}
return $storage->load($entity->id());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.