当前位置: 首页>>代码示例>>PHP>>正文


PHP RequestInterface::setClient方法代码示例

本文整理汇总了PHP中Guzzle\Http\Message\RequestInterface::setClient方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestInterface::setClient方法的具体用法?PHP RequestInterface::setClient怎么用?PHP RequestInterface::setClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Guzzle\Http\Message\RequestInterface的用法示例。


在下文中一共展示了RequestInterface::setClient方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepareRequest

 /**
  * Prepare a request to be sent from the Client by adding client specific behaviors and properties to the request.
  *
  * @param RequestInterface $request Request to prepare for the client
  * @param array            $options Options to apply to the request
  *
  * @return RequestInterface
  */
 protected function prepareRequest(RequestInterface $request, array $options = array())
 {
     $request->setClient($this)->setEventDispatcher(clone $this->getEventDispatcher());
     if ($curl = $this->config[self::CURL_OPTIONS]) {
         $request->getCurlOptions()->overwriteWith(CurlHandle::parseCurlConfig($curl));
     }
     if ($params = $this->config[self::REQUEST_PARAMS]) {
         Version::warn('request.params is deprecated. Use request.options to add default request options.');
         $request->getParams()->overwriteWith($params);
     }
     if ($this->userAgent && !$request->hasHeader('User-Agent')) {
         $request->setHeader('User-Agent', $this->userAgent);
     }
     if ($defaults = $this->config[self::REQUEST_OPTIONS]) {
         $this->requestFactory->applyOptions($request, $defaults, RequestFactoryInterface::OPTIONS_AS_DEFAULTS);
     }
     if ($options) {
         $this->requestFactory->applyOptions($request, $options);
     }
     $this->dispatch('client.create_request', array('client' => $this, 'request' => $request));
     return $request;
 }
开发者ID:RHoKAustralia,项目名称:onaroll21_backend,代码行数:30,代码来源:Client.php

示例2: prepareRequest

 /**
  * Prepare a request to be sent from the Client by adding client specific behaviors and properties to the request.
  *
  * @param RequestInterface $request Request to prepare for the client
  *
  * @return RequestInterface
  */
 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;
 }
开发者ID:harmoniouscrab,项目名称:BSc_Project_Program,代码行数:23,代码来源:Client.php

示例3: prepareRequest

 /**
  * Prepare a request to be sent from the Client by adding client specific
  * behaviors and properties to the request.
  *
  * @param RequestInterface $request Request to prepare for the client
  *
  * @return RequestInterface
  */
 protected function prepareRequest(RequestInterface $request)
 {
     $request->setClient($this);
     // Add any curl options to the request
     $request->getCurlOptions()->merge(CurlHandle::parseCurlConfig($this->config));
     foreach ($this->config as $key => $value) {
         if (strpos($key, 'params.') === 0) {
             // Add request specific parameters to all requests (prefix with 'params.')
             $request->getParams()->set(substr($key, 7), $value);
         }
     }
     // Attach client observers to the request
     $request->setEventDispatcher(clone $this->getEventDispatcher());
     $this->dispatch('client.create_request', array('client' => $this, 'request' => $request));
     return $request;
 }
开发者ID:vieiragabriel,项目名称:moodle-block_gchat,代码行数:24,代码来源:Client.php

示例4: prepareRequest

 /**
  * Prepare a request to be sent from the Client by adding client specific
  * behaviors and properties to the request.
  *
  * @param RequestInterface $request Request to prepare for the client
  *
  * @return RequestInterface
  */
 protected function prepareRequest(RequestInterface $request)
 {
     $request->setClient($this);
     foreach ($this->getConfig()->getAll() as $key => $value) {
         if ($key == 'curl.blacklist') {
             continue;
         }
         // Add any curl options that might in the config to the request
         if (strpos($key, 'curl.') === 0) {
             $curlOption = substr($key, 5);
             // Convert constants represented as string to constant int values
             if (defined($curlOption)) {
                 $value = is_string($value) && defined($value) ? constant($value) : $value;
                 $curlOption = constant($curlOption);
             }
             $request->getCurlOptions()->set($curlOption, $value);
         } elseif (strpos($key, 'params.') === 0) {
             // Add request specific parameters to all requests (prefix with 'params.')
             $request->getParams()->set(substr($key, 7), $value);
         }
     }
     // Attach client observers to the request
     $request->setEventDispatcher(clone $this->getEventDispatcher());
     $this->dispatch('client.create_request', array('client' => $this, 'request' => $request));
     return $request;
 }
开发者ID:norv,项目名称:guzzle,代码行数:34,代码来源:Client.php

示例5: prepareRequest

 /**
  * Prepare a request to be sent from the Client by adding client specific behaviors and properties to the request.
  *
  * @param RequestInterface $request Request to prepare for the client
  *
  * @return RequestInterface
  */
 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());
     // Set the User-Agent if one is specified on the client but not explicitly on the request
     if ($this->userAgent && !$request->hasHeader('User-Agent')) {
         $request->setHeader('User-Agent', $this->userAgent);
     }
     $this->dispatch('client.create_request', array('client' => $this, 'request' => $request));
     return $request;
 }
开发者ID:creazy412,项目名称:vmware-win10-c65-drupal7,代码行数:27,代码来源:Client.php


注:本文中的Guzzle\Http\Message\RequestInterface::setClient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。