1. 8.2.x core/modules/serialization/src/EntityResolver/UuidResolver.php UuidResolver
  2. 8.0.x core/modules/serialization/src/EntityResolver/UuidResolver.php UuidResolver
  3. 8.1.x core/modules/serialization/src/EntityResolver/UuidResolver.php UuidResolver
  4. 8.3.x core/modules/serialization/src/EntityResolver/UuidResolver.php UuidResolver

Resolves entities from data that contains an entity UUID.


Expanded class hierarchy of UuidResolver

2 files declare their use of UuidResolver
NormalizerTestBase.php in core/modules/hal/tests/src/Kernel/NormalizerTestBase.php
UuidResolverTest.php in core/modules/serialization/tests/src/Unit/EntityResolver/UuidResolverTest.php
1 string reference to 'UuidResolver'
serialization.services.yml in core/modules/serialization/serialization.services.yml


core/modules/serialization/src/EntityResolver/UuidResolver.php, line 11


View source
class UuidResolver implements EntityResolverInterface {

   * The entity manager.
   * @var \Drupal\Core\Entity\EntityManagerInterface
  protected $entityManager;

   * Constructs a UuidResolver object.
   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
   *   The entity manager.
  public function __construct(EntityManagerInterface $entity_manager) {
    $this->entityManager = $entity_manager;

   * {@inheritdoc}
  public function resolve(NormalizerInterface $normalizer, $data, $entity_type) {
    // The normalizer is what knows the specification of the data being
    // deserialized. If it can return a UUID from that data, and if there's an
    // entity with that UUID, then return its ID.
    if (($normalizer instanceof UuidReferenceInterface) && ($uuid = $normalizer->getUuid($data))) {
      if ($entity = $this->entityManager->loadEntityByUuid($entity_type, $uuid)) {
        return $entity->id();
    return NULL;



Contains filters are case sensitive
Namesort descending Modifiers Type Description
UuidResolver::$entityManager protected property The entity manager.
UuidResolver::resolve public function Returns the local ID of an entity referenced by serialized data. Overrides EntityResolverInterface::resolve
UuidResolver::__construct public function Constructs a UuidResolver object.