function TargetIdResolver::resolve

Same name in other branches
  1. 9 core/modules/serialization/src/EntityResolver/TargetIdResolver.php \Drupal\serialization\EntityResolver\TargetIdResolver::resolve()
  2. 10 core/modules/serialization/src/EntityResolver/TargetIdResolver.php \Drupal\serialization\EntityResolver\TargetIdResolver::resolve()
  3. 11.x core/modules/serialization/src/EntityResolver/TargetIdResolver.php \Drupal\serialization\EntityResolver\TargetIdResolver::resolve()

Overrides EntityResolverInterface::resolve

File

core/modules/serialization/src/EntityResolver/TargetIdResolver.php, line 15

Class

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

Namespace

Drupal\serialization\EntityResolver

Code

public function resolve(NormalizerInterface $normalizer, $data, $entity_type) {
    if (isset($data['target_id'])) {
        return $data['target_id'];
    }
    return NULL;
}

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