/**
  * {@inheritdoc}
  */
 protected function handleResults(Model $result)
 {
     // Get the list of objects and record the last key
     $objects = $result->get('Contents') ?: array();
     $numObjects = count($objects);
     $lastKey = $numObjects ? $objects[$numObjects - 1]['Key'] : false;
     if ($lastKey && !$result->hasKey($this->get('token_key'))) {
         $result->set($this->get('token_key'), $lastKey);
     }
     // Closure for getting the name of an object or prefix
     $getName = function ($object) {
         return isset($object['Key']) ? $object['Key'] : $object['Prefix'];
     };
     // If common prefixes returned (i.e. a delimiter was set) and they need to be returned, there is more to do
     if ($this->get('return_prefixes') && $result->hasKey('CommonPrefixes')) {
         // Collect and format the prefixes to include with the objects
         $objects = array_merge($objects, $result->get('CommonPrefixes'));
         // Sort the objects and prefixes to maintain alphabetical order, but only if some of each were returned
         if ($this->get('sort_results') && $lastKey && $objects) {
             usort($objects, function ($object1, $object2) use($getName) {
                 return strcmp($getName($object1), $getName($object2));
             });
         }
     }
     // If only the names are desired, iterate through the results and convert the arrays to the object/prefix names
     if ($this->get('names_only')) {
         $objects = array_map($getName, $objects);
     }
     return $objects;
 }
 /**
  * {@inheritdoc}
  */
 protected function handleResults(Model $result)
 {
     // Get the list of uploads
     $uploads = $result->get('Uploads') ?: array();
     // If there are prefixes and we want them, merge them in
     if ($this->get('return_prefixes') && $result->hasKey('CommonPrefixes')) {
         $uploads = array_merge($uploads, $result->get('CommonPrefixes'));
     }
     return $uploads;
 }
 /**
  * {@inheritdoc}
  */
 protected function handleResults(Model $result)
 {
     // Get the list of object versions
     $versions = $result->get('Versions') ?: array();
     $deleteMarkers = $result->get('DeleteMarkers') ?: array();
     $versions = array_merge($versions, $deleteMarkers);
     // If there are prefixes and we want them, merge them in
     if ($this->get('return_prefixes') && $result->hasKey('CommonPrefixes')) {
         $versions = array_merge($versions, $result->get('CommonPrefixes'));
     }
     return $versions;
 }
Exemplo n.º 4
0
 /**
  * Creates a credentials object from the credential data return by an STS operation
  *
  * @param Model $result The result of an STS operation
  *
  * @return Credentials
  * @throws InvalidArgumentException if the result does not contain credential data
  */
 public function createCredentials(Model $result)
 {
     if (!$result->hasKey('Credentials')) {
         throw new InvalidArgumentException('The modeled result provided contained no credentials.');
     }
     return new Credentials($result->getPath('Credentials/AccessKeyId'), $result->getPath('Credentials/SecretAccessKey'), $result->getPath('Credentials/SessionToken'), $result->getPath('Credentials/Expiration'));
 }
 public function fromModel(Model $model)
 {
     if ($model->hasKey('domainInfo')) {
         $domainInfo = $model->get('domainInfo');
         $this->fromArray($domainInfo);
         if (array_key_exists('name', $domainInfo)) {
             $this->setName($domainInfo['name']);
         }
         if (array_key_exists('status', $domainInfo)) {
             $this->setStatus($domainInfo['status']);
         }
         if (array_key_exists('description', $domainInfo)) {
             $this->setDescription($domainInfo['description']);
         }
     }
     if ($model->hasKey('configuration')) {
         $configuration = $model->get('configuration');
         if (array_key_exists('workflowExecutionRetentionPeriodInDays', $configuration)) {
             $this->setWorkflowExecutionRetentionPeriodInDays($configuration['workflowExecutionRetentionPeriodInDays']);
         }
     }
 }