From 3b4554d2673d79313626a4c395be23fe66e8b074 Mon Sep 17 00:00:00 2001 From: Dave Hall Date: Thu, 18 Oct 2012 00:09:57 +1100 Subject: [PATCH] Issue #1481372 by ericas, skwashd, Xano: Add entity_uri() callback for files --- entity.module | 3 +++ modules/callbacks.inc | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/entity.module b/entity.module index 2af9f47..a657245 100644 --- a/entity.module +++ b/entity.module @@ -1384,6 +1384,9 @@ function _entity_info_add_metadata(&$entity_info) { $entity_info['node']['form callback'] = 'entity_metadata_form_node'; $entity_info['user']['form callback'] = 'entity_metadata_form_user'; + // URI callbacks. + $entity_info['file']['uri callback'] = 'entity_metadata_uri_file'; + // View callbacks. $entity_info['node']['view callback'] = 'entity_metadata_view_node'; $entity_info['user']['view callback'] = 'entity_metadata_view_single'; diff --git a/modules/callbacks.inc b/modules/callbacks.inc index 5203028..40f9f5b 100644 --- a/modules/callbacks.inc +++ b/modules/callbacks.inc @@ -946,3 +946,13 @@ function entity_metadata_field_query($entity_type, $property, $value, $limit) { $result = $query->execute(); return !empty($result[$entity_type]) ? array_keys($result[$entity_type]) : array(); } + +/** + * Implements entity_uri() callback for file entities. + */ +function entity_metadata_uri_file($file) { + return array( + 'path' => file_create_url($file->uri), + ); +} + -- 1.7.9.5