コード例 #1
0
 /**
  * @param RequestInterface $request
  * @return array
  */
 protected function getRequestDispatchOptions(RequestInterface $request)
 {
     $url = $request->getUrl();
     $options = array_replace($this->getOptions(), [CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => $this->getRequestDispatchHeaders($request), CURLOPT_TIMEOUT => $request->getTimeout()]);
     $options[CURLOPT_CUSTOMREQUEST] = $request->getMethod();
     $params = $request->getParams();
     switch ($options[CURLOPT_CUSTOMREQUEST]) {
         case 'POST':
             $options[CURLOPT_POSTFIELDS] = $request->getData();
         case 'GET':
             $glue = strpos($url, '?') !== false ? '&' : '?';
             $url .= $params ? $glue . http_build_query($params) : null;
             break;
     }
     $options[CURLOPT_URL] = $url;
     return $options;
 }
コード例 #2
0
 /**
  * @param RequestInterface $request
  * @return void
  */
 public function prepare(RequestInterface $request)
 {
     $xml = $this->getCheckoutAsXml();
     $charset = $this->checkout->getCharset();
     $request->setData($xml)->setCharset($charset)->setHeaders(['Content-Type' => 'application/xml; charset=' . $charset]);
 }