function ResourceObject::toUrl
Same name in other branches
- 9 core/modules/jsonapi/src/JsonApiResource/ResourceObject.php \Drupal\jsonapi\JsonApiResource\ResourceObject::toUrl()
- 8.9.x core/modules/jsonapi/src/JsonApiResource/ResourceObject.php \Drupal\jsonapi\JsonApiResource\ResourceObject::toUrl()
- 10 core/modules/jsonapi/src/JsonApiResource/ResourceObject.php \Drupal\jsonapi\JsonApiResource\ResourceObject::toUrl()
Gets a Url for the ResourceObject.
Return value
\Drupal\Core\Url The URL for the identified resource object.
Throws
\LogicException Thrown if the resource object is not locatable.
See also
\Drupal\jsonapi\ResourceType\ResourceTypeRepository::isLocatableResourceType()
File
-
core/
modules/ jsonapi/ src/ JsonApiResource/ ResourceObject.php, line 217
Class
- ResourceObject
- Represents a JSON:API resource object.
Namespace
Drupal\jsonapi\JsonApiResourceCode
public function toUrl() {
foreach ($this->links as $key => $link) {
if ($key === 'self') {
$first = reset($link);
return $first->getUri();
}
}
throw new \LogicException('A Url does not exist for this resource object because its resource type is not locatable.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.