Drupal 9 Entity.repository Load Entity By UUID

[Solved] Drupal 9 Entity.repository Load Entity By UUID | Php Frameworks Drupal - Code Explorer | yomemimo.com
Question : Drupal 9 entity.repository load entity by UUID

Answered by : cheryl-mcnamee

use Symfony\Component\HttpKernel\Exception\HttpException;
$node_uuid = 'UUID STRING HERE';
try { $node = \Drupal::service('entity.repository')->loadEntityByUuid('node', $node_uuid); $nid = $node->id(); unset($node);
} catch (Exception $e) { throw new HttpException(400, 'Node UUID does not match one in the system.');
}

Source : | Last Update : Tue, 11 Jan 22

Answers related to Drupal 9 entity.repository load entity by UUID

Code Explorer Popular Question For Php Frameworks Drupal