/** * Load the connection adapter * * While this method is not called more than one for a client, it is * seperated from ->request() to preserve logic and readability * * @param \Zend\Http\Client\Adapter|string $adapter * @return null * @throws \Zend\Http\Client\Exception */ public function setAdapter($adapter) { if (is_string($adapter)) { if (!class_exists($adapter)) { throw new Client\Exception('Unable to locate adapter class "' . $adapter . '"'); } $adapter = new $adapter(); } if (!$adapter instanceof Client\Adapter) { throw new Client\Exception('Passed adapter is not a HTTP connection adapter'); } $this->adapter = $adapter; $config = $this->config; unset($config['adapter']); $this->adapter->setConfig($config); }
/** * Load the connection adapter * * While this method is not called more than one for a client, it is * seperated from ->request() to preserve logic and readability * * @param \Zend\HTTP\Client\Adapter|string $adapter * @return null * @throws \Zend\HTTP\Client\Exception */ public function setAdapter($adapter) { if (is_string($adapter)) { $adapter = new $adapter(); } if (!$adapter instanceof Client\Adapter) { throw new Client\Exception('Passed adapter is not a HTTP connection adapter'); } $this->adapter = $adapter; $config = $this->config; unset($config['adapter']); $this->adapter->setConfig($config); }