// The links array might contain URI templates set in annotations.
$link_templates =
$this->
linkTemplates();
// Links pointing to the current revision point to the actual entity. So
// instead of using the 'revision' link, use the 'canonical' link.
if ($rel === 'revision' &&
$this instanceof RevisionableInterface &&
$this->
isDefaultRevision()) { $rel = 'canonical';
} if (isset($link_templates[$rel])) { $route_parameters =
$this->
urlRouteParameters($rel);
$route_name = "entity.{
$this->entityTypeId
}." .
str_replace(['-', 'drupal:'
],
['_', ''
],
$rel);
$uri =
new Url($route_name,
$route_parameters);
} else { $bundle =
$this->
bundle();
// A bundle-specific callback takes precedence over the generic one for
// the entity type.
$bundles =
$this->
entityTypeBundleInfo()->
getBundleInfo($this->
getEntityTypeId());
if (isset($bundles[$bundle]['uri_callback'
])) { $uri_callback =
$bundles[$bundle]['uri_callback'
];
}