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


PHP Collection::get方法代码示例

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


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

示例1: onRequestBeforeSend

 /**
  * Request before-send event handler.
  *
  * @param \Guzzle\Common\Event $event
  */
 public function onRequestBeforeSend(Event $event)
 {
     $apiKey = $this->config->get('api_key');
     $username = $this->config->get('username');
     $password = $this->config->get('password');
     $this->addApiKey($event['request'], $apiKey)->addAuthorizationHeader($event['request'], $username, $password);
 }
开发者ID:cpliakas,项目名称:bigoven-php,代码行数:12,代码来源:BigOvenAuthPlugin.php

示例2: defaultMissingFunction

 /**
  * Default method to execute when credentials are not specified
  *
  * @param Collection $config Config options
  *
  * @return CredentialsInterface
  */
 protected function defaultMissingFunction(Collection $config)
 {
     if ($config->get(Options::KEY) && $config->get(Options::SECRET)) {
         // Credentials were not provided, so create them using keys
         return Credentials::factory($config->getAll());
     }
     // Attempt to get credentials from the EC2 instance profile server
     return new RefreshableInstanceProfileCredentials(new Credentials('', '', '', 1));
 }
开发者ID:noahkim,项目名称:kowop,代码行数:16,代码来源:CredentialsOptionResolver.php

示例3: getConfigFilename

 /**
  * @param string $group
  *
  * @return string
  */
 public function getConfigFilename($group)
 {
     $conf_files = $this->config->get('conf_files');
     if (!isset($conf_files[$group])) {
         $filename = $this->config['conf_dir'] . '/' . $group . '.json';
         $conf_files[$group] = $filename;
     }
     $this->config->set('conf_files', $conf_files);
     return $conf_files[$group];
 }
开发者ID:caxy,项目名称:acquia-sdk-php,代码行数:15,代码来源:ServiceManager.php

示例4: fromResult

 /**
  * Collects items from the result of a DynamoDB operation and returns them as an ItemIterator.
  *
  * @param Collection $result  The result of a DynamoDB operation that potentially contains items
  *                            (e.g., BatchGetItem, DeleteItem, GetItem, PutItem, Query, Scan, UpdateItem)
  *
  * @return self
  */
 public static function fromResult(Collection $result)
 {
     if (!($items = $result->get('Items'))) {
         if ($item = $result->get('Item') ?: $result->get('Attributes')) {
             $items = array($item);
         } else {
             $items = $result->getPath('Responses/*');
         }
     }
     return new self(new \ArrayIterator($items ?: array()));
 }
开发者ID:risyasin,项目名称:webpagetest,代码行数:19,代码来源:ItemIterator.php

示例5: enqueueGetRequests

 /**
  * Create a collection of files to be migrated and add them to the read queue
  */
 protected function enqueueGetRequests()
 {
     $files = $this->oldContainer->objectList(array('limit.total' => false, 'limit.page' => $this->options->get('read.pageLimit')));
     foreach ($files as $file) {
         $this->readQueue->add($this->getClient()->get($file->getUrl()));
     }
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:10,代码来源:ContainerMigration.php

示例6: retrieveAccessToken

 /**
  * Retrieve access token
  * 
  * @param Collection $config
  * 
  * @return string
  */
 protected static function retrieveAccessToken(Collection $config)
 {
     $client = new \Guzzle\Http\Client($config->get('oauth2_token'));
     $request = $client->get();
     $query = $request->getQuery();
     $query->set('grant_type', $config->get('grant_type'));
     $query->set('client_id', $config->get('client_id'));
     $query->set('client_secret', $config->get('client_secret'));
     $query->set('api_key', $config->get('api_key'));
     try {
         $response = $request->send();
         $json = $response->json();
     } catch (\Guzzle\Http\Exception\BadResponseException $ex) {
         throw new \Exception('Bad authentification, please check your oauth settings');
     }
     return $json['access_token'];
 }
开发者ID:mtxserv,项目名称:mtxserv-php,代码行数:24,代码来源:Client.php

示例7: testImplementsArrayAccess

 /**
  * @covers Guzzle\Common\Collection::offsetGet
  * @covers Guzzle\Common\Collection::offsetSet
  * @covers Guzzle\Common\Collection::offsetUnset
  * @covers Guzzle\Common\Collection::offsetExists
  */
 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:jsnshrmn,项目名称:Suma,代码行数:17,代码来源:CollectionTest.php

示例8: testConstructorCallsResolvers

 public function testConstructorCallsResolvers()
 {
     $config = new Collection(array(Options::ENDPOINT_PROVIDER => $this->getMock('Aws\\Common\\Region\\EndpointProviderInterface')));
     $signature = new SignatureV4();
     $credentials = new Credentials('test', '123');
     $config->set('client.resolvers', array(new BackoffOptionResolver(function () {
         return BackoffPlugin::getExponentialBackoff();
     })));
     $client = $this->getMockBuilder('Aws\\Common\\Client\\AbstractClient')->setConstructorArgs(array($credentials, $signature, $config))->getMockForAbstractClass();
     // Ensure that lazy resolvers were triggered
     $this->assertInstanceOf('Guzzle\\Plugin\\Backoff\\BackoffPlugin', $client->getConfig(Options::BACKOFF));
     // Ensure that the client removed the option
     $this->assertNull($config->get('client.resolvers'));
 }
开发者ID:noahkim,项目名称:kowop,代码行数:14,代码来源:AbstractClientTest.php

示例9: resolve

 /**
  * {@inheritdoc}
  */
 public function resolve(Collection $config, AwsClientInterface $client = null)
 {
     // A user can inject the plugin in their options array or have one
     // created for them by default
     $plugin = $config->get(Options::BACKOFF);
     if (!$plugin && $this->missingFunction) {
         $plugin = call_user_func($this->missingFunction, $config, $client);
         $config->set(Options::BACKOFF, $plugin);
         // The log option can be set to `debug` or an instance of a LogAdapterInterface
         if ($logger = $config->get(Options::BACKOFF_LOGGER)) {
             $this->addLogger($plugin, $logger, $config->get(Options::BACKOFF_LOGGER_TEMPLATE));
         }
     }
     // Ensure that the plugin implements the correct interface
     if ($plugin && !$plugin instanceof BackoffPlugin) {
         throw new InvalidArgumentException(Options::BACKOFF . ' must be an instance of Guzzle\\Plugin\\Backoff\\BackoffPlugin');
     }
     // Attach the BackoffPlugin to the client
     if ($client) {
         $client->addSubscriber($plugin, -255);
     }
 }
开发者ID:noahkim,项目名称:kowop,代码行数:25,代码来源:BackoffOptionResolver.php

示例10: resolve

 /**
  * {@inheritdoc}
  */
 public function resolve(Collection $config, AwsClientInterface $client = null)
 {
     $signature = $config->get(Options::SIGNATURE);
     // Ensure that a signature object is passed to the client
     if (!$signature && $this->missingFunction) {
         // The signature was not provided, so use the callback to get one
         $signature = call_user_func($this->missingFunction, $config);
         $config->set(Options::SIGNATURE, $signature);
     } elseif (!$signature instanceof $this->mustImplement) {
         throw new InvalidArgumentException('An explicitly provided ' . Options::SIGNATURE . ' option must implement SignatureInterface');
     }
     // If this is a region and service specific signature object then add
     // these values to the signature object if they are present in the config
     if ($signature instanceof EndpointSignatureInterface) {
         if ($serviceName = $config->get(Options::SIGNATURE_SERVICE)) {
             $signature->setServiceName($serviceName);
         }
         if ($regionName = $config->get(Options::SIGNATURE_REGION)) {
             $signature->setRegionName($regionName);
         }
     }
 }
开发者ID:romainneutron,项目名称:aws-sdk-php,代码行数:25,代码来源:SignatureOptionResolver.php

示例11: testReturnsCorrectData

 /**
  * @dataProvider falseyDataProvider
  */
 public function testReturnsCorrectData($a, $b)
 {
     $c = new Collection(array('value' => $a));
     $this->assertSame($b, $c->get('value'));
 }
开发者ID:alvarobfdev,项目名称:applog,代码行数:8,代码来源:CollectionTest.php

示例12: addSignature

 /**
  * Return an appropriate signature object for a a client based on a description
  *
  * @param ServiceDescription $description Description that holds a signature option
  * @param Collection         $config      Configuration options
  *
  * @throws InvalidArgumentException
  */
 protected function addSignature(ServiceDescription $description, Collection $config)
 {
     if (!($signature = $config->get(Options::SIGNATURE))) {
         if (!$description->getData('signatureVersion')) {
             throw new InvalidArgumentException('The service description does not specify a signatureVersion');
         }
         switch ($description->getData('signatureVersion')) {
             case 'v2':
                 $signature = new SignatureV2();
                 break;
             case 'v3':
                 $signature = new SignatureV3();
                 break;
             case 'v3https':
                 $signature = new SignatureV3Https();
                 break;
             case 'v4':
                 $signature = new SignatureV4();
                 break;
         }
     }
     // Allow a custom service name or region value to be provided
     if ($signature instanceof EndpointSignatureInterface) {
         $signature->setServiceName($config->get(Options::SIGNATURE_SERVICE) ?: $description->getData('signingName'));
         $signature->setRegionName($config->get(Options::SIGNATURE_REGION));
     }
     $config->set(Options::SIGNATURE, $signature);
 }
开发者ID:noahkim,项目名称:kowop,代码行数:36,代码来源:ClientBuilder.php

示例13: addBaseUrlToConfig

 /**
  * Add a base URL to the client of a region, scheme, and service were provided instead
  *
  * @param Collection $config Config object
  *
  * @throws InvalidArgumentException if required parameters are not set
  */
 protected function addBaseUrlToConfig(Collection $config)
 {
     $region = $config->get(Options::REGION);
     $service = $config->get(Options::SERVICE);
     if (!$region || !$service) {
         throw new InvalidArgumentException('You must specify a [base_url] or a [region, service, and optional scheme]');
     }
     $endpoint = $config->get(Options::ENDPOINT_PROVIDER)->getEndpoint($service, $region);
     $config->set(Options::BASE_URL, $endpoint->getBaseUrl($config->get(Options::SCHEME)));
 }
开发者ID:romainneutron,项目名称:aws-sdk-php,代码行数:17,代码来源:ClientBuilder.php

示例14: validate

 /**
  * {@inheritdoc}
  * @throws ValidationException when validation errors occur
  */
 public function validate(Collection $config, Inspector $inspector = null)
 {
     $inspector = $inspector ?: Inspector::getInstance();
     $typeValidation = $inspector->getTypeValidation();
     $errors = array();
     foreach ($this->params as $name => $arg) {
         $currentValue = $config->get($name);
         $configValue = $arg->getValue($currentValue);
         // Inject configuration information into the config value
         if ($configValue && is_string($configValue)) {
             $configValue = $config->inject($configValue);
         }
         // Ensure that required arguments are set
         if ($arg->getRequired() && ($configValue === null || $configValue === '')) {
             $errors[] = 'Requires that the ' . $name . ' argument be supplied.' . ($arg->getDoc() ? '  (' . $arg->getDoc() . ').' : '');
             continue;
         }
         // Ensure that the correct data type is being used
         if ($typeValidation && $configValue !== null && ($argType = $arg->getType())) {
             $validation = $inspector->validateConstraint($argType, $configValue, $arg->getTypeArgs());
             if ($validation !== true) {
                 $errors[] = $name . ': ' . $validation;
                 $config->set($name, $configValue);
                 continue;
             }
         }
         $configValue = $arg->filter($configValue);
         // Update the config value if it changed
         if (!$configValue !== $currentValue) {
             $config->set($name, $configValue);
         }
         // Check the length values if validating data
         $argMinLength = $arg->getMinLength();
         if ($argMinLength && strlen($configValue) < $argMinLength) {
             $errors[] = 'Requires that the ' . $name . ' argument be >= ' . $arg->getMinLength() . ' characters.';
         }
         $argMaxLength = $arg->getMaxLength();
         if ($argMaxLength && strlen($configValue) > $argMaxLength) {
             $errors[] = 'Requires that the ' . $name . ' argument be <= ' . $arg->getMaxLength() . ' characters.';
         }
     }
     if (!empty($errors)) {
         $e = new ValidationException('Validation errors: ' . implode("\n", $errors));
         $e->setErrors($errors);
         throw $e;
     }
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:51,代码来源:ApiCommand.php

示例15: getSignature

 /**
  * Return an appropriate signature object for a a client based on a description
  *
  * @param ServiceDescription $description Description that holds a signature option
  * @param Collection         $config      Configuration options
  *
  * @return SignatureInterface
  * @throws InvalidArgumentException
  */
 protected function getSignature(ServiceDescription $description, Collection $config)
 {
     if (!($signature = $config->get(Options::SIGNATURE))) {
         switch ($description->getData('signatureVersion')) {
             case 'v2':
                 $signature = new SignatureV2();
                 break;
             case 'v3':
                 $signature = new SignatureV3();
                 break;
             case 'v3https':
                 $signature = new SignatureV3Https();
                 break;
             case 'v4':
                 $signature = new SignatureV4();
                 break;
             default:
                 throw new InvalidArgumentException('Service description does not specify a valid signatureVersion');
         }
     }
     // Allow a custom service name or region value to be provided
     if ($signature instanceof EndpointSignatureInterface) {
         // Determine the service name to use when signing
         if (!($service = $config->get(Options::SIGNATURE_SERVICE))) {
             if (!($service = $description->getData('signingName'))) {
                 $service = $description->getData('endpointPrefix');
             }
         }
         $signature->setServiceName($service);
         // Determine the region to use when signing requests
         if (!($region = $config->get(Options::SIGNATURE_REGION))) {
             $region = $config->get(Options::REGION);
         }
         $signature->setRegionName($region);
     }
     return $signature;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:46,代码来源:ClientBuilder.php


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