You are here

public function RelationLinkManager::getRelationUri in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/rest/src/LinkManager/RelationLinkManager.php \Drupal\rest\LinkManager\RelationLinkManager::getRelationUri()

Gets the URI that corresponds to a field.

When using hypermedia formats, this URI can be used to indicate which field the data represents. Documentation about this field can also be provided at this URI.

Parameters

string $entity_type: The bundle's entity type.

string $bundle: The bundle name.

string $field_name: The field name.

array $context: (optional) Optional serializer/normalizer context.

Return value

string The corresponding URI for the field.

Overrides RelationLinkManagerInterface::getRelationUri

1 call to RelationLinkManager::getRelationUri()
RelationLinkManager::writeCache in core/modules/rest/src/LinkManager/RelationLinkManager.php
Writes the cache of relation links.

File

core/modules/rest/src/LinkManager/RelationLinkManager.php, line 64
Contains \Drupal\rest\LinkManager\RelationLinkManager.

Class

RelationLinkManager

Namespace

Drupal\rest\LinkManager

Code

public function getRelationUri($entity_type, $bundle, $field_name, $context = array()) {

  // Per the interface documention of this method, the returned URI may
  // optionally also serve as the URL of a documentation page about this
  // field. However, the REST module does not currently implement such
  // a documentation page. Therefore, we return a URI assembled relative to
  // the site's base URL, which is sufficient to uniquely identify the site's
  // entity type + bundle + field for use in hypermedia formats, but we do
  // not take into account unclean URLs, language prefixing, or anything else
  // that would be required for Drupal to be able to respond with content
  // at this URL. If a module is installed that adds such content, but
  // requires this URL to be different (e.g., include a language prefix),
  // then the module must also override the RelationLinkManager class/service
  // to return the desired URL.
  $uri = $this
    ->getLinkDomain() . "/rest/relation/{$entity_type}/{$bundle}/{$field_name}";
  $this->moduleHandler
    ->alter('rest_relation_uri', $uri, $context);
  return $uri;
}