ChainEntityResolver
class ChainEntityResolver implements ChainEntityResolverInterface (View source)
Resolver delegating the entity resolution to a chain of resolvers.
Properties
| protected EntityResolverInterface[] | $resolvers | The concrete resolvers. |
Methods
Constructs a ChainEntityResolver object.
Returns the local ID of an entity referenced by serialized data.
Details
__construct(array $resolvers = [])
Constructs a ChainEntityResolver object.
addResolver(EntityResolverInterface $resolver)
Adds an entity resolver.
string|null
resolve(NormalizerInterface $normalizer, array $data, string $entity_type)
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.