forked from parse-community/parse-php-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParseConfig.php
More file actions
109 lines (100 loc) · 2.06 KB
/
Copy pathParseConfig.php
File metadata and controls
109 lines (100 loc) · 2.06 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/**
* Class ParseConfig | Parse/ParseConfig.php
*/
namespace Parse;
/**
* Class ParseConfig - For accessing Parse Config settings.
*
* @author Fosco Marotto <fjm@fb.com>
* @package Parse
*/
class ParseConfig
{
/**
* Current configuration data
*
* @var array
*/
private $currentConfig;
/**
* ParseConfig constructor.
*/
public function __construct()
{
$result = ParseClient::_request('GET', 'config');
$this->setConfig($result['params']);
}
/**
* Gets a config value
*
* @param string $key Key of value to get
* @return mixed
*/
public function get($key)
{
if (isset($this->currentConfig[$key])) {
return $this->currentConfig[$key];
}
return null;
}
/**
* Sets a config value
*
* @param string $key Key to set value on
* @param mixed $value Value to set
*/
public function set($key, $value)
{
$this->currentConfig[$key] = $value;
}
/**
* Gets a config value with html characters encoded
*
* @param string $key Key of value to get
* @return string|null
*/
public function escape($key)
{
if (isset($this->currentConfig[$key])) {
return htmlentities($this->currentConfig[$key]);
}
return null;
}
/**
* Sets the config
*
* @param array $config Config to set
*/
protected function setConfig($config)
{
$this->currentConfig = $config;
}
/**
* Gets the current config
*
* @return array
*/
public function getConfig()
{
return $this->currentConfig;
}
/**
* Saves the current config
*
* @return bool
*/
public function save()
{
$response = ParseClient::_request(
'PUT',
'config',
null,
json_encode([
'params' => $this->currentConfig
]),
true
);
return $response['result'];
}
}