X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FEntity%2FEntity.php;h=95e85e21a4209b559d5fa56dc4cefbb2d1cfb2eb;hp=f36f74fe6790384c362f6a64a38d61786644e7be;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/lib/Drupal/Core/Entity/Entity.php b/web/core/lib/Drupal/Core/Entity/Entity.php index f36f74fe6..95e85e21a 100644 --- a/web/core/lib/Drupal/Core/Entity/Entity.php +++ b/web/core/lib/Drupal/Core/Entity/Entity.php @@ -13,6 +13,7 @@ use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Link; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Url; +use Symfony\Component\Routing\Exception\RouteNotFoundException; /** * Defines a base entity class. @@ -323,7 +324,19 @@ abstract class Entity implements EntityInterface { * {@inheritdoc} */ public function uriRelationships() { - return array_keys($this->linkTemplates()); + return array_filter(array_keys($this->linkTemplates()), function ($link_relation_type) { + // It's not guaranteed that every link relation type also has a + // corresponding route. For some, additional modules or configuration may + // be necessary. The interface demands that we only return supported URI + // relationships. + try { + $this->toUrl($link_relation_type)->toString(TRUE)->getGeneratedUrl(); + } + catch (RouteNotFoundException $e) { + return FALSE; + } + return TRUE; + }); } /**