コード例 #1
0
 public function getBatches($size = null)
 {
     $items = $this->results;
     $mapFn = $this->toBatchFn;
     if ($size) {
         $items = \Aws\partition(\Aws\flatmap($items, $mapFn), $size);
         $mapFn = function ($resources) {
             return new Batch($this->client, $this->type, $resources);
         };
     }
     return \Aws\map($items, $mapFn);
 }
コード例 #2
0
 public function makeCollection($name, array $args, Resource $parent)
 {
     if (isset($args[0]) && is_array($args[0])) {
         $args = $args[0];
     }
     // Get the information on how to process the collection.
     $info = $this->model->search('collection', $parent->getType(), $name);
     // Create a paginator or an iterator that yields a single command's result.
     $command = $this->prepareCommand($info['request'], $parent, $args);
     if ($this->apiClient->getApi()->hasPaginator($command->getName())) {
         $paginator = $this->apiClient->getPaginator($command->getName(), $command->toArray());
     } else {
         $paginator = \Aws\map([$command], function (Command $command) {
             return $this->apiClient->execute($command);
         });
     }
     // Create a new from the paginator, including a lambda that coverts
     // results to batches by using info from the resources model.
     return new Collection($this, $parent->getType(), $paginator, function (Result $result) use($info, $parent, $command) {
         $ids = $this->createIdentityForRelatedResource($info['resource']['identifiers'], function (array $param) use($parent, $command, $result) {
             return $this->resolveValue($param, $parent, $command, $result);
         });
         return $ids === null ? new Batch($this, $info['resource']['type'], []) : $this->createResources($info['resource'], $result, $ids);
     });
 }