You are here

protected function EntityReferenceRevisionsOrphanRemovalForBaseFieldDefinitionTest::getEntityHostByName in Entity Reference Revisions 8

Get an entity host from the database based on its name.

Parameters

string $name: A entity name.

bool $reset: (optional) Whether to reset the entity cache.

Return value

\Drupal\Core\Entity\RevisionableInterface A revisionable entity matching $name.

2 calls to EntityReferenceRevisionsOrphanRemovalForBaseFieldDefinitionTest::getEntityHostByName()
EntityReferenceRevisionsOrphanRemovalForBaseFieldDefinitionTest::insertNonRevisionableData in tests/src/Functional/EntityReferenceRevisionsOrphanRemovalForBaseFieldDefinitionTest.php
Inserts non revisionable entities needed for testing.
EntityReferenceRevisionsOrphanRemovalForBaseFieldDefinitionTest::insertRevisionableData in tests/src/Functional/EntityReferenceRevisionsOrphanRemovalForBaseFieldDefinitionTest.php
Inserts revisionable entities needed for testing.

File

tests/src/Functional/EntityReferenceRevisionsOrphanRemovalForBaseFieldDefinitionTest.php, line 231

Class

EntityReferenceRevisionsOrphanRemovalForBaseFieldDefinitionTest
Tests orphan composite revisions are properly removed.

Namespace

Drupal\Tests\entity_reference_revisions\Functional

Code

protected function getEntityHostByName($name, $reset = FALSE) {
  if ($reset) {
    \Drupal::entityTypeManager()
      ->getStorage('entity_host_relationship_test')
      ->resetCache();
  }
  $name = (string) $name;

  /** @var \Drupal\Core\Entity\RevisionableInterface[] $entities */
  $entities = \Drupal::entityTypeManager()
    ->getStorage('entity_host_relationship_test')
    ->loadByProperties([
    'name' => $name,
  ]);

  // Load the first entity returned from the database.
  return reset($entities);
}