Problem/Motivation
If a file entity is loaded, a call to link()
function ($entity->link()
), results in following exception:
Drupal\Core\Entity\Exception\UndefinedLinkTemplateException: No link template "canonical" found for the "file" entity type in Drupal\Core\Entity\Entity->urlInfo() (line 188 of /var/www/html/drupal8/core/lib/Drupal/Core/Entity/Entity.php).