From 4445858df2fd31780d86e9b38a39ef612ec7c00f Mon Sep 17 00:00:00 2001 From: Jordan Dukart Date: Fri, 24 Jul 2015 11:00:37 -0300 Subject: [PATCH] Allow modules to modify which object is being loaded. --- includes/metadata.inc | 4 ++++ islandora.api.php | 22 ++++++++++++++++++++++ islandora.module | 2 ++ 3 files changed, 28 insertions(+) diff --git a/includes/metadata.inc b/includes/metadata.inc index bf59b830..9a75cd05 100644 --- a/includes/metadata.inc +++ b/includes/metadata.inc @@ -20,6 +20,8 @@ function islandora_retrieve_metadata_markup(AbstractObject $object, $print = FAL $viewer = variable_get('islandora_metadata_display', 'dublin_core'); $markup = ''; if (isset($viewers[$viewer]['metadata callback'])) { + $hooks = islandora_build_hook_list(ISLANDORA_METADATA_OBJECT_ALTER, $object->models); + drupal_alter($hooks, $object); $markup = call_user_func($viewers[$viewer]['metadata callback'], $object, $print); // The callback doesn't have any markup provided for this particular object, // default back to the dublin_core display. @@ -44,6 +46,8 @@ function islandora_retrieve_description_markup(AbstractObject $object) { $viewer = variable_get('islandora_metadata_display', 'dublin_core'); $markup = ''; if (isset($viewers[$viewer]['description callback'])) { + $hooks = islandora_build_hook_list(ISLANDORA_METADATA_OBJECT_DESCRIPTION_ALTER, $object->models); + drupal_alter($hooks, $object); $markup = call_user_func($viewers[$viewer]['description callback'], $object); // The callback doesn't have any markup provided for this particular object, // default back to the dublin_core display. diff --git a/islandora.api.php b/islandora.api.php index e7026923..dda2d20b 100644 --- a/islandora.api.php +++ b/islandora.api.php @@ -794,3 +794,25 @@ function hook_islandora_metadata_display_info() { ), ); } + +/** + * Allows modifications to the object whose metadata is being rendered. + * + * @param AbstractObject $object + * An AbstractObject representing an object within Fedora. + */ +function hook_islandora_metadata_object_alter(AbstractObject &$object) { + $this_other_object = islandora_object_load('awild:indirectionappears'); + $object = $this_other_object; +} + +/** + * Allows modifications to the object whose metadata is being rendered. + * + * @param AbstractObject $object + * An AbstractObject representing an object within Fedora. + */ +function hook_islandora_metadata_object_description_alter(AbstractObject &$object) { + $this_other_object = islandora_object_load('awild:indirectionappears'); + $object = $this_other_object; +} diff --git a/islandora.module b/islandora.module index 10d6060f..884e534c 100644 --- a/islandora.module +++ b/islandora.module @@ -49,6 +49,8 @@ define('ISLANDORA_POST_INGEST_HOOK', 'islandora_ingest_post_ingest'); define('ISLANDORA_PRE_PURGE_OBJECT_HOOK', 'islandora_pre_purge_object'); define('ISLANDORA_POST_PURGE_OBJECT_HOOK', 'islandora_post_purge_object'); define('ISLANDORA_UPDATE_RELATED_OBJECTS_PROPERTIES_HOOK', 'islandora_update_related_objects_properties'); +define('ISLANDORA_METADATA_OBJECT_ALTER', 'islandora_metadata_object'); +define('ISLANDORA_METADATA_OBJECT_DESCRIPTION_ALTER', 'islandora_metadata_object_description'); // @todo Add Documentation. define('ISLANDORA_OBJECT_INGESTED_HOOK', 'islandora_object_ingested');