function EntityResourceTestBase::getEntityResourceUrl

Same name and namespace in other branches
  1. 11.x core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::getEntityResourceUrl()
  2. 10 core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::getEntityResourceUrl()
  3. 8.9.x core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::getEntityResourceUrl()

Gets an entity resource's GET/PATCH/DELETE URL.

Return value

\Drupal\Core\Url The URL to GET/PATCH/DELETE.

File

core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php, line 1220

Class

EntityResourceTestBase
Defines a base class for testing all entity resources.

Namespace

Drupal\Tests\rest\Functional\EntityResource

Code

protected function getEntityResourceUrl() {
  $has_canonical_url = $this->entity
    ->hasLinkTemplate('canonical');
  // Note that the 'canonical' link relation type must be specified explicitly
  // in the call to ::toUrl(). 'canonical' is the default for
  // \Drupal\Core\Entity\Entity::toUrl(), but ConfigEntityBase overrides this.
  return $has_canonical_url ? $this->entity
    ->toUrl('canonical') : Url::fromUri('base:entity/' . static::$entityTypeId . '/' . $this->entity
    ->id());
}

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