public function EntityNG::uri

Implements \Drupal\Core\Entity\EntityInterface::uri().

Overrides Entity::uri

1 method overrides EntityNG::uri()
CustomBlock::uri in drupal/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php
Implements \Drupal\Core\Entity\EntityInterface::uri().

File

drupal/core/lib/Drupal/Core/Entity/EntityNG.php, line 148
Contains \Drupal\Core\Entity\EntityNG.

Class

EntityNG
Implements Entity Field API specific enhancements to the Entity class.

Namespace

Drupal\Core\Entity

Code

public function uri($rel = 'canonical') {
  $entity_info = $this
    ->entityInfo();
  $link_templates = isset($entity_info['links']) ? $entity_info['links'] : array();
  if (isset($link_templates[$rel])) {
    $template = $link_templates[$rel];
    $replacements = $this
      ->uriPlaceholderReplacements();
    $uri['path'] = str_replace(array_keys($replacements), array_values($replacements), $template);

    // @todo Remove this once http://drupal.org/node/1888424 is in and we can
    //   move the BC handling of / vs. no-/ to the generator.
    $uri['path'] = trim($uri['path'], '/');

    // Pass the entity data to url() so that alter functions do not need to
    // look up this entity again.
    $uri['options']['entity_type'] = $this->entityType;
    $uri['options']['entity'] = $this;
    return $uri;
  }

  // For a canonical link (that is, a link to self), look up the stack for
  // default logic. Other relationship types are not supported by parent
  // classes.
  if ($rel == 'canonical') {
    return parent::uri();
  }
}