Goutte\Client::getClient PHP Method

getClient() public method

public getClient ( )
    public function getClient()
    {
        if (!$this->client) {
            $this->client = new GuzzleClient(array('defaults' => array('allow_redirects' => false, 'cookies' => true)));
        }
        return $this->client;
    }

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::getClient