Created
June 11, 2014 13:02
-
-
Save morozov/5c47a4438efaf83ee674 to your computer and use it in GitHub Desktop.
Proxy Switcher decorator for Guzzle loader
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 | |
use Guzzle\Http\ClientInterface; | |
use Valera\Loader\LoaderInterface; | |
use Valera\Resource; | |
use Valera\Loader\Result; | |
class ProxySwitcher implements LoaderInterface | |
{ | |
/** | |
* @var Valera\Loader\LoaderInterface | |
*/ | |
private $loader; | |
/** | |
* @var Guzzle\Http\ClientInterface | |
*/ | |
private $client; | |
public function __construct(LoaderInterface $loader, ClientInterface $client) | |
{ | |
$this->loader = $loader; | |
$this->client = $client; | |
} | |
public function load(Resource $resource, Result $result) | |
{ | |
$config = $this->getConfig(); | |
$this->client->setConfig($config); | |
$this->loader->load($resource, $result); | |
} | |
} | |
$guzzle = new Guzzle\Http\Client(); | |
$loader = new Valera\Loader\Guzzle($guzzle); | |
$proxy = new ProxySwitcher($loader, $guzzle); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment