You are here

function hook_rest_relation_uri_alter in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/rest/rest.api.php \hook_rest_relation_uri_alter()

Alter the REST relation URI.

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

Parameters

string $uri: The URI to alter.

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

See also

\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.

rest_test_rest_relation_uri_alter in core/modules/rest/tests/modules/rest_test/rest_test.module
Implements hook_rest_relation_uri_alter().
1 invocation of hook_rest_relation_uri_alter()
RelationLinkManager::getRelationUri in core/modules/rest/src/LinkManager/RelationLinkManager.php
Gets the URI that corresponds to a field.

File

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

Code

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