function EntityBase::uriRelationships

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/EntityBase.php \Drupal\Core\Entity\EntityBase::uriRelationships()
  2. 10 core/lib/Drupal/Core/Entity/EntityBase.php \Drupal\Core\Entity\EntityBase::uriRelationships()
  3. 11.x core/lib/Drupal/Core/Entity/EntityBase.php \Drupal\Core\Entity\EntityBase::uriRelationships()

Overrides EntityInterface::uriRelationships

File

core/lib/Drupal/Core/Entity/EntityBase.php, line 284

Class

EntityBase
Defines a base entity class.

Namespace

Drupal\Core\Entity

Code

public function uriRelationships() {
    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;
        } catch (MissingMandatoryParametersException $e) {
            return FALSE;
        }
        return TRUE;
    });
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.