Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 /**
|
Chris@0
|
4 * @file
|
Chris@0
|
5 * Describes hooks provided by the HAL module.
|
Chris@0
|
6 */
|
Chris@0
|
7
|
Chris@0
|
8 /**
|
Chris@0
|
9 * @addtogroup hooks
|
Chris@0
|
10 * @{
|
Chris@0
|
11 */
|
Chris@0
|
12
|
Chris@0
|
13 /**
|
Chris@0
|
14 * Alter the HAL type URI.
|
Chris@0
|
15 *
|
Chris@0
|
16 * Modules may wish to alter the type URI generated for a resource based on the
|
Chris@0
|
17 * context of the serializer/normalizer operation.
|
Chris@0
|
18 *
|
Chris@0
|
19 * @param string $uri
|
Chris@0
|
20 * The URI to alter.
|
Chris@0
|
21 * @param array $context
|
Chris@0
|
22 * The context from the serializer/normalizer operation.
|
Chris@0
|
23 *
|
Chris@0
|
24 * @see \Symfony\Component\Serializer\SerializerInterface::serialize()
|
Chris@0
|
25 * @see \Symfony\Component\Serializer\SerializerInterface::deserialize()
|
Chris@0
|
26 * @see \Symfony\Component\Serializer\NormalizerInterface::normalize()
|
Chris@0
|
27 * @see \Symfony\Component\Serializer\DenormalizerInterface::denormalize()
|
Chris@0
|
28 */
|
Chris@0
|
29 function hook_hal_type_uri_alter(&$uri, $context = []) {
|
Chris@0
|
30 if ($context['mymodule'] == TRUE) {
|
Chris@0
|
31 $base = \Drupal::config('hal.settings')->get('link_domain');
|
Chris@0
|
32 $uri = str_replace($base, 'http://mymodule.domain', $uri);
|
Chris@0
|
33 }
|
Chris@0
|
34 }
|
Chris@0
|
35
|
Chris@0
|
36 /**
|
Chris@0
|
37 * Alter the HAL relation URI.
|
Chris@0
|
38 *
|
Chris@0
|
39 * Modules may wish to alter the relation URI generated for a resource based on
|
Chris@0
|
40 * the context of the serializer/normalizer operation.
|
Chris@0
|
41 *
|
Chris@0
|
42 * @param string $uri
|
Chris@0
|
43 * The URI to alter.
|
Chris@0
|
44 * @param array $context
|
Chris@0
|
45 * The context from the serializer/normalizer operation.
|
Chris@0
|
46 *
|
Chris@0
|
47 * @see \Symfony\Component\Serializer\SerializerInterface::serialize()
|
Chris@0
|
48 * @see \Symfony\Component\Serializer\SerializerInterface::deserialize()
|
Chris@0
|
49 * @see \Symfony\Component\Serializer\NormalizerInterface::normalize()
|
Chris@0
|
50 * @see \Symfony\Component\Serializer\DenormalizerInterface::denormalize()
|
Chris@0
|
51 */
|
Chris@0
|
52 function hook_hal_relation_uri_alter(&$uri, $context = []) {
|
Chris@0
|
53 if ($context['mymodule'] == TRUE) {
|
Chris@0
|
54 $base = \Drupal::config('hal.settings')->get('link_domain');
|
Chris@0
|
55 $uri = str_replace($base, 'http://mymodule.domain', $uri);
|
Chris@0
|
56 }
|
Chris@0
|
57 }
|
Chris@0
|
58
|
Chris@0
|
59 /**
|
Chris@0
|
60 * @} End of "addtogroup hooks".
|
Chris@0
|
61 */
|