Prepare a request to be sent from the Client by adding client specific behaviors and properties to the request.
RequestInterface $request Request to prepare for the client:
protected function prepareRequest(RequestInterface $request) {
$request
->setClient($this);
// Add any curl options to the request
if ($options = $this->config
->get(self::CURL_OPTIONS)) {
$request
->getCurlOptions()
->merge(CurlHandle::parseCurlConfig($options));
}
// Add request parameters to the request
if ($options = $this->config
->get(self::REQUEST_PARAMS)) {
$request
->getParams()
->merge($options);
}
// Attach client observers to the request
$request
->setEventDispatcher(clone $this
->getEventDispatcher());
$this
->dispatch('client.create_request', array(
'client' => $this,
'request' => $request,
));
return $request;
}