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


PHP Collection::merge方法代码示例

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


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

示例1: getGuzzleClient

 /**
  * @param type $baseUrl
  * @param type $config
  * @return \Guzzle\Http\Client
  */
 public function getGuzzleClient($baseUrl = '', $config = null)
 {
     if (!is_null($config)) {
         $this->config->merge($config);
     }
     return new Client($baseUrl, $this->config);
 }
开发者ID:guilhermednt,项目名称:http-service-bundle,代码行数:12,代码来源:ClientFactory.php

示例2: testImplementsArrayAccess

 public function testImplementsArrayAccess()
 {
     $this->coll->merge(array('k1' => 'v1', 'k2' => 'v2'));
     $this->assertTrue($this->coll->offsetExists('k1'));
     $this->assertFalse($this->coll->offsetExists('Krull'));
     $this->coll->offsetSet('k3', 'v3');
     $this->assertEquals('v3', $this->coll->offsetGet('k3'));
     $this->assertEquals('v3', $this->coll->get('k3'));
     $this->coll->offsetUnset('k1');
     $this->assertFalse($this->coll->offsetExists('k1'));
 }
开发者ID:alvarobfdev,项目名称:applog,代码行数:11,代码来源:CollectionTest.php

示例3: onRequestRetry

 /**
  * Called when a request is being retried
  *
  * @param Event $event Event emitted
  */
 public function onRequestRetry(Event $event)
 {
     $request = $event['request'];
     $response = $event['response'];
     $handle = $event['handle'];
     $data = new Collection(array('ts' => gmdate('c'), 'method' => $request->getMethod(), 'url' => $request->getUrl(), 'retries' => $event['retries'], 'delay' => $event['delay']));
     if ($response) {
         $data->merge(array('code' => $response->getStatusCode(), 'phrase' => $response->getReasonPhrase(), 'connect_time' => $response->getInfo('connect_time'), 'total_time' => $response->getInfo('total_time')));
     } elseif ($handle) {
         $data->merge(array('connect_time' => $handle->getInfo(CURLINFO_CONNECT_TIME), 'total_time' => $handle->getInfo(CURLINFO_TOTAL_TIME)));
     }
     if ($handle) {
         $data->set('curl_error', $handle->getError());
         $data->set('curl_code', $handle->getErrorNo());
     }
     // Add request headers to the possible template values
     foreach ($request->getHeaders(true) as $header => $value) {
         $data->set("header_{$header}", (string) $value);
     }
     $this->logger->log($data->inject($this->template), LOG_INFO, $data);
 }
开发者ID:vieiragabriel,项目名称:moodle-block_gchat,代码行数:26,代码来源:ExponentialBackoffLogger.php

示例4: getParamsToSign

 public function getParamsToSign(RequestInterface $request, $timestamp, $nonce)
 {
     $params = new Collection(array('oauth_consumer_key' => $this->config['consumer_key'], 'oauth_nonce' => $nonce, 'oauth_signature_method' => $this->config['signature_method'], 'oauth_timestamp' => $timestamp, 'oauth_version' => $this->config['version']));
     // Filter out oauth_token during temp token step, as in request_token.
     if ($this->config['token'] !== false) {
         $params->add('oauth_token', $this->config['token']);
     }
     // Add call back uri
     if (isset($this->config['callback_uri']) && !empty($this->config['callback_uri'])) {
         $params->add('oauth_callback', $this->config['callback_uri']);
     }
     // Add query string parameters
     $params->merge($request->getQuery());
     // Add POST fields to signing string
     if (!$this->config->get('disable_post_params') && $request instanceof EntityEnclosingRequestInterface && false !== strpos($request->getHeader('Content-Type'), 'application/x-www-form-urlencoded')) {
         $params->merge($request->getPostFields());
     }
     // Sort params
     $params = $params->getAll();
     ksort($params);
     return $params;
 }
开发者ID:vdmi,项目名称:guzzle-oauth,代码行数:22,代码来源:OauthPlugin.php

示例5: getParamsToSign

 /**
  * Parameters sorted and filtered in order to properly sign a request
  *
  * @param RequestInterface $request   Request to generate a signature for
  * @param integer          $timestamp Timestamp to use for nonce
  * @param string           $nonce
  *
  * @return array
  */
 public function getParamsToSign(RequestInterface $request, $timestamp, $nonce)
 {
     $params = new Collection(array('oauth_consumer_key' => $this->config['consumer_key'], 'oauth_nonce' => $nonce, 'oauth_signature_method' => $this->config['signature_method'], 'oauth_timestamp' => $timestamp, 'oauth_token' => $this->config['token'], 'oauth_version' => $this->config['version']));
     if (array_key_exists('callback', $this->config) == true) {
         $params['oauth_callback'] = $this->config['callback'];
     }
     if (array_key_exists('verifier', $this->config) == true) {
         $params['oauth_verifier'] = $this->config['verifier'];
     }
     // Add query string parameters
     $params->merge($request->getQuery());
     // Add POST fields to signing string if required
     if ($this->shouldPostFieldsBeSigned($request)) {
         $params->merge($request->getPostFields());
     }
     // Sort params
     $params = $params->toArray();
     ksort($params);
     return $params;
 }
开发者ID:diandianxiyu,项目名称:Yii2Api,代码行数:29,代码来源:OauthPlugin.php

示例6: getStringToSign

 /**
  * Calculate string to sign
  *
  * @param RequestInterface $request Request to generate a signature for
  * @param int $timestamp Timestamp to use for nonce
  *
  * @return string
  */
 public function getStringToSign(RequestInterface $request, $timestamp)
 {
     $params = new Collection(array('oauth_consumer_key' => $this->config['consumer_key'], 'oauth_nonce' => $this->generateNonce($request, $timestamp), 'oauth_signature_method' => $this->config['signature_method'], 'oauth_timestamp' => $timestamp, 'oauth_token' => $this->config['token'], 'oauth_version' => $this->config['version']));
     // Add query string parameters
     $params->merge($request->getQuery());
     // Add POST fields to signing string
     if ($request instanceof EntityEnclosingRequestInterface && $request->getHeader('Content-Type') == 'application/x-www-form-urlencoded') {
         $params->merge($request->getPostFields());
     }
     // Sort params
     $params = $params->getAll();
     ksort($params);
     // Build signing string from combined params
     $parameterString = array();
     foreach ($params as $key => $values) {
         $key = rawurlencode($key);
         $values = (array) $values;
         sort($values);
         foreach ($values as $value) {
             if (is_bool($value)) {
                 $value = $value ? 'true' : 'false';
             }
             $parameterString[] = $key . '=' . rawurlencode($value);
         }
     }
     $url = Url::factory($request->getUrl())->setQuery('')->setFragment('');
     return strtoupper($request->getMethod()) . '&' . rawurlencode($url) . '&' . rawurlencode(implode('&', $parameterString));
 }
开发者ID:MicroSDHC,项目名称:justinribeiro.com-examples,代码行数:36,代码来源:OauthPlugin.php


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