Skip to content

Commit

Permalink
Added a way to debug the calls made to the server.
Browse files Browse the repository at this point in the history
  • Loading branch information
travist committed Jan 1, 2012
1 parent 1eca308 commit 759afcd
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions Server.php
Expand Up @@ -147,7 +147,7 @@ protected function send() {
* Called to validate the response of the request.
*/
protected function validate() {

// If errors occur, then call the onError method in the request object.
if ($errors = $this->errors()) {
if (method_exists($this->request, 'onError')) {
Expand All @@ -168,6 +168,25 @@ public function errors() {
return array();
}

/**
* Debugs the current call.
*/
protected function debug() {

// If they wish to debug the call, then do so here.
if (isset($this->config['debug']) && ($debug = $this->config['debug'])) {
$debug(array(
'method' => $this->request->getMethod(),
'path' => $this->request->getUrl()->getPath(),
'query' => $this->request->getUrl()->getQuery(),
'params' => $this->request->getBody(),
'errors' => $this->errors()
));
}

return $this;
}

/**
* Performs a server call.
*/
Expand All @@ -188,7 +207,8 @@ public function call($endpoint, $method = HTTP_Request2::METHOD_GET, $params = a
->authenticate() /** Authenticate the request */
->send() /** Send the request. */
->decode() /** Decode the response. */
->validate(); /** Validate the response. */
->validate() /** Validate the response. */
->debug(); /** Debug the call. */

// Return the this pointer.
return $this;
Expand Down

0 comments on commit 759afcd

Please sign in to comment.