Ejemplo n.º 1
0
 /**
  * Update a configuration object from a service description
  *
  * @param Collection $config Config to update
  *
  * @return ServiceDescription
  * @throws InvalidArgumentException
  */
 protected function updateConfigFromDescription(Collection $config)
 {
     $description = $config->get(Options::SERVICE_DESCRIPTION);
     if (!$description instanceof ServiceDescription) {
         // Inject the version into the sprintf template if it is a string
         if (is_string($description)) {
             $description = sprintf($description, $config->get(Options::VERSION));
         }
         $description = ServiceDescription::factory($description);
         $config->set(Options::SERVICE_DESCRIPTION, $description);
     }
     if (!$config->get(Options::SERVICE)) {
         $config->set(Options::SERVICE, $description->getData('endpointPrefix'));
     }
     if ($iterators = $description->getData('iterators')) {
         $this->setIteratorsConfig($iterators);
     }
     // Make sure a valid region is set
     $region = $config->get(Options::REGION);
     $global = $description->getData('globalEndpoint');
     if (!$global && !$region) {
         throw new InvalidArgumentException('A region is required when using ' . $description->getData('serviceFullName'));
     } elseif ($global && (!$region || $description->getData('namespace') !== 'S3')) {
         $region = 'us-east-1';
         $config->set(Options::REGION, 'us-east-1');
     }
     if (!$config->get(Options::BASE_URL)) {
         $endpoint = call_user_func($config->get('endpoint_provider'), array('scheme' => $config->get(Options::SCHEME), 'region' => $region, 'service' => $config->get(Options::SERVICE)));
         $config->set(Options::BASE_URL, $endpoint['endpoint']);
         // Set a signature if one was not explicitly provided.
         if (!$config->hasKey(Options::SIGNATURE) && isset($endpoint['signatureVersion'])) {
             $config->set(Options::SIGNATURE, $endpoint['signatureVersion']);
         }
     }
     return $description;
 }
Ejemplo n.º 2
0
 /**
  * @deprecated Use $message->getHeader()->parseParams()
  * @codeCoverageIgnore
  */
 public function getTokenizedHeader($header, $token = ';')
 {
     Version::warn(__METHOD__ . ' is deprecated. Use $message->getHeader()->parseParams()');
     if ($this->hasHeader($header)) {
         $data = new Collection();
         foreach ($this->getHeader($header)->parseParams() as $values) {
             foreach ($values as $key => $value) {
                 if ($value === '') {
                     $data->set($data->count(), $key);
                 } else {
                     $data->add($key, $value);
                 }
             }
         }
         return $data;
     }
 }