function entity_uri

cis7 common.inc entity_uri($entity_type, $entity)
cle7 common.inc entity_uri($entity_type, $entity)
elmsmedia7 common.inc entity_uri($entity_type, $entity)
icor7 common.inc entity_uri($entity_type, $entity)
meedjum_blog7 common.inc entity_uri($entity_type, $entity)
mooc7 common.inc entity_uri($entity_type, $entity)

Returns the URI elements of an entity.

Parameters

$entity_type: The entity type; e.g. 'node' or 'user'.

$entity: The entity for which to generate a path.

Return value

An array containing the 'path' and 'options' keys used to build the URI of the entity, and matching the signature of url(). NULL if the entity has no URI of its own.

60 calls to entity_uri()
adaptivetheme_preprocess_comment in sites/all/themes/ulmus/adaptivetheme/at_core/inc/preprocess.inc
Preprocess variables for comment.tpl.php
ctools_context_entity_settings_form in sites/all/modules/ulmus/ctools/plugins/contexts/entity.inc
ds_entity_variables in sites/all/modules/ulmus/ds/ds.module
Add variables to an entity.
ds_extras_node_page_view in sites/all/modules/ulmus/ds/modules/ds_extras/includes/ds_extras.pages.inc
Menu callback: show an individual node with the Switch field.
ds_field_formatter_view in sites/all/modules/ulmus/ds/ds.module
Implements hook_field_formatter_view().

... See full list

File

includes/common.inc, line 7902
Common functions that many Drupal modules will need to reference.

Code

function entity_uri($entity_type, $entity) {
  $info = entity_get_info($entity_type);
  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);

  // A bundle-specific callback takes precedence over the generic one for the
  // entity type.
  if (isset($info['bundles'][$bundle]['uri callback'])) {
    $uri_callback = $info['bundles'][$bundle]['uri callback'];
  }
  elseif (isset($info['uri callback'])) {
    $uri_callback = $info['uri callback'];
  }
  else {
    return NULL;
  }

  // Invoke the callback to get the URI. If there is no callback, return NULL.
  if (isset($uri_callback) && function_exists($uri_callback)) {
    $uri = $uri_callback($entity);
    // Pass the entity data to url() so that alter functions do not need to
    // lookup this entity again.
    $uri['options']['entity_type'] = $entity_type;
    $uri['options']['entity'] = $entity;
    return $uri;
  }
}