Goutte\Client::setClient PHP Method

setClient() public method

public setClient ( GuzzleHttp\ClientInterface $client )
$client GuzzleHttp\ClientInterface
    public function setClient(GuzzleClientInterface $client)
    {
        $this->client = $client;
        return $this;
    }

Usage Example

 /**
  * {@inheritdoc}
  * @param Proxy $proxy
  *
  * @return mixed|void
  * @throws \Exception
  */
 public function setProxy(Proxy $proxy)
 {
     $sessionName = md5($proxy->getUrl());
     $this->browser->resetSessions();
     if ($this->browser->hasSession($sessionName)) {
         $this->browser->setDefaultSessionName($sessionName);
         return;
     }
     $driver = $this->browser->getSession()->getDriver();
     switch (get_class($driver)) {
         case 'Behat\\Mink\\Driver\\GoutteDriver':
             /* @var $driver  GoutteDriver */
             $client = new Client();
             $guzzle = $client->getClient();
             $client->setClient($guzzle);
             $guzzle->setDefaultOption('proxy', $proxy->getUrl());
             $goutteDriver = new GoutteDriver($client);
             $this->browser->registerSession($sessionName, new Session($goutteDriver));
             $this->browser->setDefaultSessionName($sessionName);
             break;
         default:
             throw new \Exception('Error : Proxy configuration is not implemented for class ' . get_class($driver) . '');
     }
 }
All Usage Examples Of Goutte\Client::setClient