PluginProbe
FluentSnippets – High-Performance Code Snippets, Header & Footer Code, Custom CSS & PHP Code Manager / 1.1
FluentSnippets – High-Performance Code Snippets, Header & Footer Code, Custom CSS & PHP Code Manager v1.1
10.56 1.2.1 10 10.1 10.2 10.3 10.31 10.32 10.33 10.34 10.50 10.51 10.52 10.53 10.55 9.0 9.0.1 9.4 trunk 1.0.0 1.1 1.2
easy-code-manager / framework / ServicesClientAPI / ClientModule.abstract.php

ClientModule.abstract.php in FluentSnippets – High-Performance Code Snippets, Header & Footer Code, Custom CSS & PHP Code Manager 1.1, at framework/ServicesClientAPI/ClientModule.abstract.php

141 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 *
4 */
5
6 /**
7 *
8 */
9 abstract class CJTServicesClientModule {
10
11 /**
12 * put your comment there...
13 *
14 * @var mixed
15 */
16 protected $moduleName;
17
18 /**
19 * put your comment there...
20 *
21 * @var WP_Error
22 */
23 private $response;
24
25 /**
26 * put your comment there...
27 *
28 * @var mixed
29 */
30 private $responseData;
31
32 /**
33 * put your comment there...
34 *
35 * @var mixed
36 */
37 private $servicesAPI;
38
39 /**
40 * put your comment there...
41 *
42 * @param CJTServicesClient $servicesClient
43 * @return CJTServicesClientModule
44 */
45 public function __construct(CJTServicesClient & $servicesClient)
46 {
47 # Get Services API instance
48 $this->servicesAPI =& $servicesClient;
49
50 # Allow module name to be coded from derided class
51 if (!$this->moduleName)
52 {
53 # Obtain module name from $this class name with CJT prefix removed
54 $this->moduleName = strtolower(substr(get_class($this), 3));
55 }
56 }
57
58 /**
59 * put your comment there...
60 *
61 * @param mixed $name
62 */
63 protected function get($name)
64 {
65 return isset($this->responseData[$name]) ? $this->responseData[$name] : null;
66 }
67
68 /**
69 * put your comment there...
70 *
71 */
72 public function getModuleName()
73 {
74 return $this->moduleName;
75 }
76
77 /**
78 * put your comment there...
79 *
80 */
81 public function getResponseData()
82 {
83 return $this->responseData;
84 }
85
86 /**
87 * put your comment there...
88 *
89 */
90 public function & getServicesAPI()
91 {
92 return $this->servicesAPI;
93 }
94
95 /**
96 * put your comment there...
97 *
98 * @param mixed $json
99 */
100 protected function jsonDecode( $json )
101 {
102 return json_decode( $json, true );
103 }
104
105 /**
106 * put your comment there...
107 *
108 * @param mixed $method
109 * @param mixed $params
110 * @param mixed $postData
111 * @param mixed $bodyEncoding
112 * @return CJTServicesClientModule
113 */
114 public function makeCall( $method,
115 $params = null,
116 $postData = null,
117 $bodyEncoding = CJTServicesClient::BODY_ENCODING_JSON)
118 {
119 # Reset response object
120 $this->response = null;
121 $this->responseData = null;
122
123 # Dispatch and store response
124 $this->response = $this->getServicesAPI()->makeCall(
125
126 $this->getModuleName(),
127 $method,
128 $params,
129 $postData,
130 $bodyEncoding
131 );
132
133 # Read response data
134 $this->responseData = wp_remote_retrieve_body( $this->response );
135
136 # Chain
137 return $this;
138 }
139
140 }
141