TargetIdResolver.php

Same filename in other branches
  1. 9 core/modules/serialization/src/EntityResolver/TargetIdResolver.php
  2. 8.9.x core/modules/serialization/src/EntityResolver/TargetIdResolver.php
  3. 10 core/modules/serialization/src/EntityResolver/TargetIdResolver.php

Namespace

Drupal\serialization\EntityResolver

File

core/modules/serialization/src/EntityResolver/TargetIdResolver.php

View source
<?php

namespace Drupal\serialization\EntityResolver;

use Symfony\Component\Serializer\Normalizer\NormalizerInterface;

/**
 * Resolves entities from data that contains an entity target ID.
 */
class TargetIdResolver implements EntityResolverInterface {
    
    /**
     * {@inheritdoc}
     */
    public function resolve(NormalizerInterface $normalizer, $data, $entity_type) {
        if (isset($data['target_id'])) {
            return $data['target_id'];
        }
        return NULL;
    }

}

Classes

Title Deprecated Summary
TargetIdResolver Resolves entities from data that contains an entity target ID.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.