forked from discoverygarden/islandora_rest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
islandora_rest.api.php
52 lines (50 loc) · 1.85 KB
/
islandora_rest.api.php
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
<?php
/**
* @file
* This file documents all available hook functions for the Islandora REST module.
*/
/**
* Notify modules of requests to Islandora REST endpoints other than 'solr'.
*
* @param string $endpoint
* The REST endpoint.
* @param array $request_parameters
* An array containing all request parameters.
* @param array $response
* An associative array version of the JSON response generated by the request.
* @param object $e
* The exception generated during the Solr request,
* or NULL if request was successful.
*/
function hook_islandora_rest_response($endpoint, $request_parameters, $response, $e) {
if ($e) {
$vars = array('%endpoint' => $endpoint, '%object' => $request_parameters['pid'], '%message' => $e->getMessage());
watchdog('islandora_rest', 'Islandora REST request to endpoint %endpoint for object: %object failed: %message',
$vars, WATCHDOG_ERROR);
}
else {
watchdog('islandora_rest', 'Islandora REST request to endpoint %endpoint for object: %object',
array('%endpoint' => $endpoint, '%object' => $request_parameters['pid']));
}
}
/**
* Notify modules of requests to Islandora REST 'solr' endpoint.
*
* @param array $query
* The Solr query.
* @param array $response
* The Solr query response (not the HTTP response).
* @param object $e
* The exception generated during the Solr request,
* or NULL if request was successful.
*/
function hook_islandora_rest_solr_response($query, $response, $e) {
if ($e) {
$vars = array('%query' => $query['query'], '%message' => $e->getMessage());
watchdog('islandora_rest', 'Islandora REST Solr query %query failed: %message', $vars);
}
else {
$vars = array('%query' => $query['query'], '%numfound' => $response['response']['numFound']);
watchdog('islandora_rest', 'Islandora REST Solr query %query returned %numfound objects', $vars);
}
}