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