Skip to content

Instantly share code, notes, and snippets.

@jmoz
Created May 16, 2011 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmoz/974596 to your computer and use it in GitHub Desktop.
Save jmoz/974596 to your computer and use it in GitHub Desktop.
Client example
<?php
class ServiceClient {
private $service;
private $http;
public function __construct(Service $service, Http $http) {
$this->service = $service;
$this->http = $http;
}
public function getService() {
return $this->service;
}
public function setService(Service $service) {
$this->service = $service;
}
public function call() {
sfContext::getInstance()->getLogger()->info("Calling service " . get_class($this->service) . " with url {$this->service->getUrl()}");
$this->http->setUrl($this->service->getUrl());
$this->http->setMethod($this->service->getMethod());
$this->http->setBody($this->service->getBody());
$this->http->send();
return $this->http->getResponseBody();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment