1 | <?php |
||
13 | class HTTPDataService extends BaseDataService |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * Constructor |
||
18 | * |
||
19 | * @param \Buzz\Browser $connector |
||
20 | * @param array $config |
||
21 | * @return \Gerrie\API\DataService\HTTPDataService |
||
|
|||
22 | */ |
||
23 | 9 | public function __construct(\Buzz\Browser $connector, array $config) |
|
29 | |||
30 | /** |
||
31 | * Gets the base url for all HTTP requests. |
||
32 | * |
||
33 | * @param bool $withAuthentication If true, the authentification string will be appended. False otherwise |
||
34 | * @return string |
||
35 | */ |
||
36 | protected function getBaseUrl($withAuthentication = false) |
||
53 | |||
54 | /** |
||
55 | * Verifies the last request. |
||
56 | * If the last request was not successful, it will be throw an exception. |
||
57 | * |
||
58 | * @param \Buzz\Message\Response $response The response object from the last reques |
||
59 | * @param string $url The url which was requested |
||
60 | * @return \Buzz\Message\Response |
||
61 | * @throws \Exception |
||
62 | */ |
||
63 | protected function verifyResult(\Buzz\Message\Response $response, $url) |
||
71 | |||
72 | /** |
||
73 | * Transforms a JSON string into an array. |
||
74 | * Regular, the json is the content from the response. |
||
75 | * |
||
76 | * @param string $json The json string |
||
77 | * @return array|null |
||
78 | */ |
||
79 | 2 | public function transformJsonResponse($json) |
|
90 | |||
91 | /** |
||
92 | * Initiales the query limit |
||
93 | * |
||
94 | * @return int |
||
95 | */ |
||
96 | protected function initQueryLimit() |
||
106 | |||
107 | /** |
||
108 | * Requests projects at the Gerrit server |
||
109 | * |
||
110 | * @return array|null |
||
111 | */ |
||
112 | public function getProjects() |
||
131 | |||
132 | /** |
||
133 | * Requests changesets at the Gerrit server. |
||
134 | * |
||
135 | * This method is not implemented yet, because at the moment (2013-03-24) Gerrit 2.6.* is not released. |
||
136 | * Many Gerrit systems (e.g. TYPO3, WikiMedia, OpenStack, etc.) are running at 2.5.*. |
||
137 | * In 2.5.* the SSH API delivers more information than the REST API. |
||
138 | * |
||
139 | * If Gerrit 2.6 is released, the HTTP DataService will be extended and fully implemented. |
||
140 | * Maybe, you want to help me? |
||
141 | * |
||
142 | * SSH commands: |
||
143 | * /usr/bin/ssh -p 29418 review.typo3.org gerrit query --format 'JSON' --current-patch-set |
||
144 | * --all-approvals --files --comments |
||
145 | * --commit-message --dependencies --submit-records |
||
146 | * 'project:Documentation/ApiTypo3Org' limit:'500' 2>&1 |
||
147 | * /usr/bin/ssh -p 29418 review.typo3.org gerrit query --format 'JSON' --current-patch-set |
||
148 | * --all-approvals --files --comments |
||
149 | * --commit-message --dependencies --submit-records |
||
150 | * 'project:Documentation/ApiTypo3Org' limit:'500' |
||
151 | * resume_sortkey:'00215ec7000041b3' 2>&1 |
||
152 | * |
||
153 | * @param string $projectName The project name |
||
154 | * @param string $resumeKey The key where the request will be resumed |
||
155 | * @param integer $start Number of changesets which will be skipped |
||
156 | * @return array|null |
||
157 | * @throws \Exception |
||
158 | */ |
||
159 | public function getChangesets($projectName, $resumeKey = null, $start = 0) |
||
192 | |||
193 | /** |
||
194 | * This function build a url query string with a parameter which can be applied more than one time. |
||
195 | * E.g. http://www.google.de/?q=5&q=6&q=7&q=8&q=9... |
||
196 | * |
||
197 | * This method is used to apply the parameter "o" in GET /changes/ command for REST-API. |
||
198 | * |
||
199 | * @see https://review.typo3.org/Documentation/rest-api-changes.html#list-changes |
||
200 | * |
||
201 | * @param string $parameterName Parametername which should be used more than one time |
||
202 | * @param array $values Various of values |
||
203 | * @return string |
||
204 | */ |
||
205 | private function buildQueryStringWithSameParameterName($parameterName, array $values) |
||
219 | |||
220 | /** |
||
221 | * Returns the version of the Gerrit server |
||
222 | * |
||
223 | * @link https://review.typo3.org/Documentation/rest-api-config.html |
||
224 | * |
||
225 | * @return string |
||
226 | */ |
||
227 | public function getVersion() |
||
237 | } |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.