Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\serialization\EntityResolver;
|
Chris@0
|
4
|
Chris@0
|
5 use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
Chris@0
|
6
|
Chris@0
|
7 interface EntityResolverInterface {
|
Chris@0
|
8
|
Chris@0
|
9 /**
|
Chris@0
|
10 * Returns the local ID of an entity referenced by serialized data.
|
Chris@0
|
11 *
|
Chris@0
|
12 * Drupal entities are loaded by and internally referenced by a local ID.
|
Chris@0
|
13 * Because different websites can use the same local ID to refer to different
|
Chris@0
|
14 * entities (e.g., node "1" can be a different node on foo.com and bar.com, or
|
Chris@0
|
15 * on example.com and staging.example.com), it is generally unsuitable for use
|
Chris@0
|
16 * in hypermedia data exchanges. Instead, UUIDs, URIs, or other globally
|
Chris@0
|
17 * unique IDs are preferred.
|
Chris@0
|
18 *
|
Chris@0
|
19 * This function takes a $data array representing partially deserialized data
|
Chris@0
|
20 * for an entity reference, and resolves it to a local entity ID. For example,
|
Chris@0
|
21 * depending on the data specification being used, $data might contain a
|
Chris@0
|
22 * 'uuid' key, a 'uri' key, a 'href' key, or some other data identifying the
|
Chris@0
|
23 * entity, and it is up to the implementor of this interface to resolve that
|
Chris@0
|
24 * appropriately for the specification being used.
|
Chris@0
|
25 *
|
Chris@0
|
26 * @param \Symfony\Component\Serializer\Normalizer\NormalizerInterface $normalizer
|
Chris@0
|
27 * The Normalizer which is handling the data.
|
Chris@0
|
28 * @param array $data
|
Chris@0
|
29 * The data passed into the calling Normalizer.
|
Chris@0
|
30 * @param string $entity_type
|
Chris@0
|
31 * The type of entity being resolved; e.g., 'node' or 'user'.
|
Chris@0
|
32 *
|
Chris@0
|
33 * @return string|null
|
Chris@0
|
34 * Returns the local entity ID, if found. Otherwise, returns NULL.
|
Chris@0
|
35 */
|
Chris@0
|
36 public function resolve(NormalizerInterface $normalizer, $data, $entity_type);
|
Chris@0
|
37
|
Chris@0
|
38 }
|