-
Notifications
You must be signed in to change notification settings - Fork 1
/
apiTemplate.php
49 lines (41 loc) · 1.38 KB
/
apiTemplate.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
<?php
/**
* Template for API version specific configuration
*
* DO NOT INCLUDE THIS FILE!
*/
class api_config{
private static $settings = array(
// Set required variables in the POST and PUT calls here
'requiredVariables' => array('POST' => array('url', 'owner', 'type', 'name'),
'PUT' => array('key', 'value')),
// Name of the content node
'contentNode' => 'content',
// If you want to use a key overwrite function, set it here, and definte it below!
'overwriteKeyFunction' => 'overwriteKey'
);
public static function getSetting($key){
if (isset(self::$settings[$key])) {
return self::$settings[$key];
} else {
return false;
}
}
/**
* Override data key name as requested by caller
*
* Receives the $_POST variable in $postVars, and the current data document in $data
*/
public static function overwriteKey ($urlPath, $postVars, $data) {
if ($postVars['MY_SPECIAL_KEY']) {
if (isset($data[$postVars['MY_SPECIAL_KEY']])) {
// oh noes, we have key collision, so use some special magic to make a new key
$key = "123423423";
return $key;
}
} else {
// Don't want to do any special mapping, so just return
return null ;
}
}
}