You are here

function hook_rest_relation_uri_alter in Drupal 8

Alter the REST relation URI.

Parameters

string $uri: The URI to alter.

array $context: The context from the serializer/normalizer operation.

Deprecated

in drupal:8.3.0 and is removed from drupal:9.0.0. Use hook_hal_relation_uri_alter() instead. This exists solely for BC.

Modules may wish to alter the relation URI generated for a resource based on the context of the serializer/normalizer operation.

See also

https://www.drupal.org/node/2830467

\Symfony\Component\Serializer\SerializerInterface::serialize()

\Symfony\Component\Serializer\SerializerInterface::deserialize()

\Symfony\Component\Serializer\NormalizerInterface::normalize()

\Symfony\Component\Serializer\DenormalizerInterface::denormalize()

Related topics

1 function implements hook_rest_relation_uri_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

hal_test_rest_relation_uri_alter in core/modules/hal/tests/modules/hal_test/hal_test.module
Implements hook_rest_relation_uri_alter().

File

core/modules/rest/rest.api.php, line 80
Describes hooks provided by the RESTful Web Services module.

Code

function hook_rest_relation_uri_alter(&$uri, $context = []) {
  if ($context['mymodule'] == TRUE) {
    $base = \Drupal::config('hal.settings')
      ->get('link_domain');
    $uri = str_replace($base, 'http://mymodule.domain', $uri);
  }
}