function xmlsitemap_entity_uri in XML sitemap 6.2
Backport of entity_uri() from Drupal 7.
3 calls to xmlsitemap_entity_uri()
- xmlsitemap_node_create_link in xmlsitemap_node/
xmlsitemap_node.module - Create a sitemap link from a node.
- xmlsitemap_taxonomy_create_link in xmlsitemap_taxonomy/
xmlsitemap_taxonomy.module - Create a sitemap link from a taxonomy term.
- xmlsitemap_user_create_link in xmlsitemap_user/
xmlsitemap_user.module - Create a sitemap link from a user.
File
- ./
xmlsitemap.module, line 1593 - Main file for the xmlsitemap module.
Code
function xmlsitemap_entity_uri($entity_type, &$entity) {
// This check enables the URI of an entity to be easily overridden from what
// the callback for the entity type or bundle would return, and it helps
// minimize performance overhead when entity_uri() is called multiple times
// for the same entity.
if (!isset($entity->uri)) {
$info = xmlsitemap_get_link_info($entity_type);
list($id, , $bundle) = xmlsitemap_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 {
$uri_callback = NULL;
}
// Invoke the callback to get the URI. If there is no callback, set the
// entity's 'uri' property to FALSE to indicate that it is known to not have
// a URI.
if (isset($uri_callback) && function_exists($uri_callback)) {
$entity->uri = $uri_callback($entity);
if (!isset($entity->uri['options'])) {
$entity->uri['options'] = array();
}
// Pass the entity data to url() so that alter functions do not need to
// lookup this entity again.
//$entity->uri['options']['entity_type'] = $entity_type;
//$entity->uri['options']['entity'] = $entity;
}
else {
$entity->uri = FALSE;
}
}
return $entity->uri ? $entity->uri : NULL;
}