1 | <?php |
||
13 | class AcquiaNetworkClient extends Client implements ServiceManagerAware |
||
14 | { |
||
15 | const NONCE_LENGTH = 55; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $networkId; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $networkKey; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $serverAddress; |
||
31 | |||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $httpHost; |
||
36 | |||
37 | /** |
||
38 | * @var bool |
||
39 | */ |
||
40 | protected $https; |
||
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | * |
||
45 | * @return \Acquia\Network\AcquiaNetworkClient |
||
46 | */ |
||
47 | 39 | public static function factory($config = array()) |
|
68 | |||
69 | /** |
||
70 | * @param string $networkUri |
||
71 | * @param string $networkId |
||
72 | * @param string $networkKey |
||
73 | * @param mixed $config |
||
74 | */ |
||
75 | 39 | public function __construct($networkUri, $networkId, $networkKey, $config = null) |
|
85 | |||
86 | /** |
||
87 | * @return string |
||
88 | */ |
||
89 | 3 | public function getNetworkId() |
|
93 | |||
94 | /** |
||
95 | * @return string |
||
96 | */ |
||
97 | 13 | public function getNetworkKey() |
|
101 | |||
102 | /** |
||
103 | * {@inheritdoc} |
||
104 | */ |
||
105 | 3 | public function getBuilderParams() |
|
113 | |||
114 | /** |
||
115 | * Returns default paramaters for request. Not every call requires these. |
||
116 | * |
||
117 | * @return array |
||
118 | */ |
||
119 | 21 | protected function defaultRequestParams() |
|
129 | |||
130 | /** |
||
131 | * @param string $method |
||
132 | * @param array $params |
||
133 | * |
||
134 | * @return array |
||
135 | * |
||
136 | * @throws \fXmlRpc\Exception\ResponseException |
||
137 | */ |
||
138 | 27 | protected function call($method, array $params) |
|
148 | |||
149 | /** |
||
150 | * @param string &$errstr |
||
151 | * |
||
152 | * @return bool |
||
153 | */ |
||
154 | 6 | public function validateCredentials(&$errstr = null) |
|
166 | |||
167 | /** |
||
168 | * @return string |
||
169 | * |
||
170 | * @throws \UnexpectedValueException |
||
171 | * @throws \OutOfBoundsException |
||
172 | */ |
||
173 | 9 | public function getSubscriptionName() |
|
191 | |||
192 | /** |
||
193 | * @param string $email |
||
194 | * |
||
195 | * @return array |
||
196 | * |
||
197 | * @throws \fXmlRpc\Exception\ResponseException |
||
198 | */ |
||
199 | 3 | public function getCommunicationSettings($email) |
|
216 | |||
217 | /** |
||
218 | * @param $email |
||
219 | * @param $password |
||
220 | * |
||
221 | * @throws \fXmlRpc\Exception\ResponseException |
||
222 | */ |
||
223 | 3 | public function getSubscriptionCredentials($email, $password) |
|
243 | |||
244 | /* |
||
245 | * @params array |
||
246 | * Parameters to have signed. |
||
247 | * |
||
248 | * @return string |
||
249 | */ |
||
250 | 21 | protected function buildAuthenticator($params = array()) |
|
264 | |||
265 | /** |
||
266 | * @param array $options |
||
267 | * - search_version: An array of search module versions keyed by name. |
||
268 | * - no_heartbeat: Pass 1 to not send a heartbeat. |
||
269 | * |
||
270 | * @return \Acquia\Network\Subscription |
||
271 | */ |
||
272 | 9 | public function getSubscription(array $options = array()) |
|
280 | |||
281 | /** |
||
282 | * @param int $services |
||
283 | * |
||
284 | * @return \Acquia\Network\Subscription |
||
285 | */ |
||
286 | 3 | public function checkSubscription($services = 0) |
|
298 | |||
299 | /** |
||
300 | * @return boolean |
||
301 | */ |
||
302 | 6 | public function subscriptionActive() |
|
307 | } |
||
308 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: