From 7c2627409c897b1d5e4914382f58e631e6bf18ac Mon Sep 17 00:00:00 2001 From: Christian Selig Date: Thu, 25 Jul 2013 15:42:26 -0400 Subject: [PATCH] Moved tuque singleton creation method from within module file to utilities file. --- includes/utilities.inc | 24 ++++++++++++++++++++++++ islandora.module | 15 ++------------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/includes/utilities.inc b/includes/utilities.inc index 5ce2ca14..633801b2 100644 --- a/includes/utilities.inc +++ b/includes/utilities.inc @@ -910,3 +910,27 @@ function islandora_as_renderable_array(&$markup_array) { } unset($value); } + +/** + * Creates and returns a singleton of tuque if one does not already exist. + * + * @param object $user + * User who created the request. + * @param object $url + * URL to Fedora. + * + * @return IslandoraTuque + * An IslandoraTuque instance. + */ +function islandora_make_tuque($user, $url) { + if (IslandoraTuque::exists()) { + try { + return new IslandoraTuque($user, $url); + } + catch (Exception $e) { + drupal_set_message(t('Unable to connect to the repository %e', array('%e' => $e)), 'error'); + } + } + + return NULL; +} diff --git a/islandora.module b/islandora.module index e7e501fb..32f2b817 100644 --- a/islandora.module +++ b/islandora.module @@ -821,6 +821,8 @@ function islandora_default_islandora_view_object($object) { * A IslandoraTuque instance */ function islandora_get_tuque_connection($new_user = NULL, $url = NULL) { + module_load_include('inc', 'islandora', 'includes/utilities'); + $tuque = &drupal_static(__FUNCTION__); global $user; @@ -894,19 +896,6 @@ function islandora_get_tuque_connection($new_user = NULL, $url = NULL) { return $tuque; } -function islandora_make_tuque($user, $url) { - if (IslandoraTuque::exists()) { - try { - return new IslandoraTuque($user, $url); - } - catch (Exception $e) { - drupal_set_message(t('Unable to connect to the repository %e', array('%e' => $e)), 'error'); - } - } - - return NULL; -} - /** * Loads the object from the given ID if possible. *