forked from easySuite/ting_marc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathting_marc.client.inc
68 lines (59 loc) · 1.43 KB
/
ting_marc.client.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
* @file
* Service related function.
*/
/**
* Get object from service (cached).
*
* @param string $id
* Object identifier.
*
* @return NULL|TingMarcxchangeResult
* MarcXchange result object, or NULL on failure.
*/
function ting_marc_load_object($id) {
// Check cache.
$cid = 'marcxchange:' . $id;
$cache = cache_get($cid);
if (!empty($cache)) {
return $cache->data;
}
// Get object from service.
$object = _ting_marc_load_object($id);
cache_set($cid, $object);
return $object;
}
/**
* Get object directly from service (no cache).
*
* @param string $id
* Object identifier.
*
* @return NULL|TingMarcxchangeResult
* MarcXchange result object, or NULL on failure.
*/
function _ting_marc_load_object($id) {
module_load_include('client.inc', 'ting');
$urls = ting_marc_ting_request_factory();
$url = variable_get($urls['marcxchange']);
$request = new TingClientMarcXchangeRequest($url);
$request->setAgency(variable_get('ting_agency'));
$request->setProfile(variable_get('ting_search_profile'));
$request->setIdentifier($id);
$object = ting_execute($request);
return $object;
}
/**
* Log messages to dblog.
*
* @param string $message
* Message to be logged.
* @param array $data
* Paceholder data for message.
*/
function ting_mark_log($message, $data = array()) {
if (variable_get('ting_mark_logging', 0)) {
watchdog('ting_marc', $message, $data, WATCHDOG_DEBUG);
}
}