You are here

class TargetIdResolver in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/serialization/src/EntityResolver/TargetIdResolver.php \Drupal\serialization\EntityResolver\TargetIdResolver
  2. 10 core/modules/serialization/src/EntityResolver/TargetIdResolver.php \Drupal\serialization\EntityResolver\TargetIdResolver

Resolves entities from data that contains an entity target ID.

Hierarchy

Expanded class hierarchy of TargetIdResolver

1 string reference to 'TargetIdResolver'
serialization.services.yml in core/modules/serialization/serialization.services.yml
core/modules/serialization/serialization.services.yml
1 service uses TargetIdResolver
serialization.entity_resolver.target_id in core/modules/serialization/serialization.services.yml
Drupal\serialization\EntityResolver\TargetIdResolver

File

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

Namespace

Drupal\serialization\EntityResolver
View source
class TargetIdResolver implements EntityResolverInterface {

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

}

Members

Namesort descending Modifiers Type Description Overrides
TargetIdResolver::resolve public function Returns the local ID of an entity referenced by serialized data. Overrides EntityResolverInterface::resolve