Browse Source

Added the islandora_object_load function to the tuque wrapper

pull/132/merge^2
Jordan Dukart 12 years ago
parent
commit
9e5ad2b345
  1. 57
      api/tuque.inc

57
api/tuque.inc

@ -26,31 +26,31 @@ $islandora_module_path = drupal_get_path('module', 'fedora_repository');
class IslandoraTuque { class IslandoraTuque {
/** /**
* Connection to the repository * Connection to the repository
* *
* @var RepositoryConnection * @var RepositoryConnection
*/ */
public $connection = NULL; public $connection = NULL;
/** /**
* The Fedora API we are using * The Fedora API we are using
* *
* @var FedoraAPI * @var FedoraAPI
*/ */
public $api = NULL; public $api = NULL;
/** /**
* The cache we use to connect. * The cache we use to connect.
* *
* @var SimpleCache * @var SimpleCache
*/ */
public $cache = NULL; public $cache = NULL;
/** /**
* The repository object. * The repository object.
* *
* @var FedoraRepository * @var FedoraRepository
*/ */
public $repository = NULL; public $repository = NULL;
function __construct($user = NULL, $url = NULL) { function __construct($user = NULL, $url = NULL) {
@ -77,6 +77,7 @@ class IslandoraTuque {
$this->cache = new SimpleCache(); $this->cache = new SimpleCache();
$this->repository = new FedoraRepository($this->api, $this->cache); $this->repository = new FedoraRepository($this->api, $this->cache);
} }
} }
static function exists() { static function exists() {
@ -89,5 +90,29 @@ class IslandoraTuque {
$message = t('Islandora requires the !tuque_url. Please install in /sites/all/libraries/tuque before continuing. See the !islandora_url.', array( '!tuque_url' => $tuque_link, '!islandora_url' => $islandora_doc_link)); $message = t('Islandora requires the !tuque_url. Please install in /sites/all/libraries/tuque before continuing. See the !islandora_url.', array( '!tuque_url' => $tuque_link, '!islandora_url' => $islandora_doc_link));
drupal_set_message($message, 'error', FALSE); drupal_set_message($message, 'error', FALSE);
} }
} }
function islandora_object_load($object_id) {
static $islandora_tuque = NULL;
if(!$islandora_tuque) {
$islandora_tuque = new IslandoraTuque();
}
if(IslandoraTuque::exists()) {
try {
$fedora_object = $islandora_tuque->repository->getObject($object_id);
} catch (Exception $e) {
return NULL;
}
return $fedora_object;
}
else {
IslandoraTuque::getError();
return NULL;
}
}

Loading…
Cancel
Save