From 83c97345e8eada544d7da4586e2c77db469ed5b1 Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Wed, 13 Jan 2010 06:26:49 +0000 Subject: #525622 by Frando, yched, et al: Add entity hook callbacks so that 'as link' formatters have a generic way to build the url of an 'entity'. --- includes/common.inc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'includes/common.inc') diff --git a/includes/common.inc b/includes/common.inc index 8d5f637d3..f8fb336c6 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -6524,6 +6524,23 @@ function entity_prepare_view($entity_type, $entities) { } } +/** + * Returns the path to an entity. + * + * @param $entity_type + * The entity type; e.g. 'node' or 'user'. + * @param $entity + * The entity for which to generate a path. + * @return + * The path for the entity, or NULL if the entity has no page of its own. + */ +function entity_path($entity_type, $entity) { + $info = entity_get_info($entity_type); + if (isset($info['path callback']) && function_exists($info['path callback'])) { + return $info['path callback']($entity); + } +} + /** * Performs one or more XML-RPC request(s). * -- cgit v1.2.3