Commit 6fb9d191 authored by alexpott's avatar alexpott

Issue #2423951 by effulgentsia, joelpittet, dawehner, klausi: Document each...

Issue #2423951 by effulgentsia, joelpittet, dawehner, klausi: Document each use of base: in rest.module
parent 7599b055
......@@ -62,6 +62,18 @@ public function __construct(CacheBackendInterface $cache, EntityManagerInterface
* {@inheritdoc}
*/
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;
......
......@@ -12,6 +12,10 @@ interface RelationLinkManagerInterface extends ConfigurableLinkManagerInterface
/**
* 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.
*
* @param string $entity_type
* The bundle's entity type.
* @param string $bundle
......
......@@ -49,19 +49,21 @@ public function __construct(CacheBackendInterface $cache, ModuleHandlerInterface
}
/**
* Get a type link for a bundle.
*
* @param string $entity_type
* The bundle's entity type.
* @param string $bundle
* The name of the bundle.
* @param array $context
* Context of normalizer/serializer.
*
* @return string
* The URI that identifies this bundle.
* {@inheritdoc}
*/
public function getTypeUri($entity_type, $bundle, $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
// bundle. 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 and bundle 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 TypeLinkManager class/service to
// return the desired URL.
$uri = $this->getLinkDomain() . "/rest/type/$entity_type/$bundle";
$this->moduleHandler->alter('rest_type_uri', $uri, $context);
return $uri;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment