public function Entity::uri

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

Overrides EntityInterface::uri

1 call to Entity::uri()
EntityNG::uri in drupal/core/lib/Drupal/Core/Entity/EntityNG.php
Implements \Drupal\Core\Entity\EntityInterface::uri().
8 methods override Entity::uri()
Action::uri in drupal/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/Action.php
Implements \Drupal\Core\Entity\EntityInterface::uri().
Block::uri in drupal/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php
Overrides \Drupal\Core\Entity\Entity::uri();
CustomBlockType::uri in drupal/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlockType.php
Overrides \Drupal\Core\Entity\Entity::uri().
EntityNG::uri in drupal/core/lib/Drupal/Core/Entity/EntityNG.php
Implements \Drupal\Core\Entity\EntityInterface::uri().
Role::uri in drupal/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/Role.php
Implements \Drupal\Core\Entity\EntityInterface::uri().

... See full list

File

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

Class

Entity
Defines a base entity class.

Namespace

Drupal\Core\Entity

Code

public function uri() {
  $bundle = $this
    ->bundle();

  // A bundle-specific callback takes precedence over the generic one for the
  // entity type.
  $entity_info = $this
    ->entityInfo();
  $bundles = entity_get_bundles($this->entityType);
  if (isset($bundles[$bundle]['uri_callback'])) {
    $uri_callback = $bundles[$bundle]['uri_callback'];
  }
  elseif (isset($entity_info['uri_callback'])) {
    $uri_callback = $entity_info['uri_callback'];
  }

  // Invoke the callback to get the URI. If there is no callback, use the
  // default URI format.
  if (isset($uri_callback) && function_exists($uri_callback)) {
    $uri = $uri_callback($this);
  }
  else {
    $uri = array(
      'path' => 'entity/' . $this->entityType . '/' . $this
        ->id(),
    );
  }

  // 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;
}