interface EntityResolverInterface

Same name and namespace in other branches
  1. 8.9.x core/modules/serialization/src/EntityResolver/EntityResolverInterface.php \Drupal\serialization\EntityResolver\EntityResolverInterface
  2. 10 core/modules/serialization/src/EntityResolver/EntityResolverInterface.php \Drupal\serialization\EntityResolver\EntityResolverInterface
  3. 11.x core/modules/serialization/src/EntityResolver/EntityResolverInterface.php \Drupal\serialization\EntityResolver\EntityResolverInterface

Hierarchy

Expanded class hierarchy of EntityResolverInterface

All classes that implement EntityResolverInterface

1 file declares its use of EntityResolverInterface
EntityReferenceItemNormalizer.php in core/modules/hal/src/Normalizer/EntityReferenceItemNormalizer.php

File

core/modules/serialization/src/EntityResolver/EntityResolverInterface.php, line 7

Namespace

Drupal\serialization\EntityResolver
View source
interface EntityResolverInterface {
    
    /**
     * Returns the local ID of an entity referenced by serialized data.
     *
     * Drupal entities are loaded by and internally referenced by a local ID.
     * Because different websites can use the same local ID to refer to different
     * entities (e.g., node "1" can be a different node on foo.com and bar.com, or
     * on example.com and staging.example.com), it is generally unsuitable for use
     * in hypermedia data exchanges. Instead, UUIDs, URIs, or other globally
     * unique IDs are preferred.
     *
     * This function takes a $data array representing partially deserialized data
     * for an entity reference, and resolves it to a local entity ID. For example,
     * depending on the data specification being used, $data might contain a
     * 'uuid' key, a 'uri' key, a 'href' key, or some other data identifying the
     * entity, and it is up to the implementor of this interface to resolve that
     * appropriately for the specification being used.
     *
     * @param \Symfony\Component\Serializer\Normalizer\NormalizerInterface $normalizer
     *   The Normalizer which is handling the data.
     * @param array $data
     *   The data passed into the calling Normalizer.
     * @param string $entity_type
     *   The type of entity being resolved; e.g., 'node' or 'user'.
     *
     * @return string|null
     *   Returns the local entity ID, if found. Otherwise, returns NULL.
     */
    public function resolve(NormalizerInterface $normalizer, $data, $entity_type);

}

Members

Title Sort descending Modifiers Object type Summary Overrides
EntityResolverInterface::resolve public function Returns the local ID of an entity referenced by serialized data. 3

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