You are here

public function EntityLoadHelper::loadByUuid in YAML Content 8

Load an existing entity by UUID.

Parameters

$entity_type: The type of entity being imported.

string $uuid: The UUID of the entity to be searched for.

Return value

\Drupal\Core\Entity\EntityInterface|false

1 call to EntityLoadHelper::loadByUuid()
EntityLoadHelper::loadEntity in src/Service/EntityLoadHelper.php
Load an entity matching content data if available.

File

src/Service/EntityLoadHelper.php, line 126

Class

EntityLoadHelper
A helper class to support identification and loading of existing entities.

Namespace

Drupal\yaml_content\Service

Code

public function loadByUuid($entity_type, $uuid) {

  // Load the entity type storage handler.
  $entity_handler = $this
    ->getEntityStorage($entity_type);

  // Load by searching only for the `uuid` property.
  $entities = $entity_handler
    ->loadByProperties([
    'uuid' => $uuid,
  ]);
  return reset($entities);
}