Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/hal/hal.api.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children | a9cd425dd02b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
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 /** | |
38 * Alter the HAL relation URI. | |
39 * | |
40 * Modules may wish to alter the relation URI generated for a resource based on | |
41 * the context of the serializer/normalizer operation. | |
42 * | |
43 * @param string $uri | |
44 * The URI to alter. | |
45 * @param array $context | |
46 * The context from the serializer/normalizer operation. | |
47 * | |
48 * @see \Symfony\Component\Serializer\SerializerInterface::serialize() | |
49 * @see \Symfony\Component\Serializer\SerializerInterface::deserialize() | |
50 * @see \Symfony\Component\Serializer\NormalizerInterface::normalize() | |
51 * @see \Symfony\Component\Serializer\DenormalizerInterface::denormalize() | |
52 */ | |
53 function hook_hal_relation_uri_alter(&$uri, $context = []) { | |
54 if ($context['mymodule'] == TRUE) { | |
55 $base = \Drupal::config('hal.settings')->get('link_domain'); | |
56 $uri = str_replace($base, 'http://mymodule.domain', $uri); | |
57 } | |
58 } | |
59 | |
60 /** | |
61 * @} End of "addtogroup hooks". | |
62 */ |