Created
May 16, 2011 15:00
-
-
Save jmoz/974596 to your computer and use it in GitHub Desktop.
Client example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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