thrownewEntityMalformedException(sprintf('The "%s" entity cannot have a URI as it does not have an ID',$this->getEntityTypeId()));
}
@@ -164,6 +164,19 @@ public function toUrl($rel = 'canonical', array $options = []) {
// The links array might contain URI templates set in annotations.
$link_templates=$this->linkTemplates();
// Use the canonical link template by default, or edit-form if there is not
// a canonical one.
if($rel===NULL){
$rel_candidates=array_intersect(
['canonical','edit-form'],
array_flip($link_templates),
);
$rel=array_shift($rel_candidates);
if($rel===NULL){
thrownewUndefinedLinkTemplateException("Cannot generate default URL because no link template 'canonical' or 'edit-form' was found for the '{$this->getEntityTypeId()}' entity type");
}
}
// Links pointing to the current revision point to the actual entity. So
// instead of using the 'revision' link, use the 'canonical' link.