Пример #1
0
 private function parse_structure(StructureShape $shape, \SimpleXMLElement $value)
 {
     $target = [];
     foreach ($shape->getMembers() as $name => $member) {
         // Extract the name of the XML node
         $node = $this->memberKey($member, $name);
         if (isset($value->{$node})) {
             $target[$name] = $this->dispatch($member, $value->{$node});
         }
     }
     return $target;
 }
Пример #2
0
 private function extractPayload($payload, StructureShape $output, ResponseInterface $response, array &$result)
 {
     $member = $output->getMember($payload);
     if ($member instanceof StructureShape) {
         // Structure members parse top-level data into a specific key.
         $result[$payload] = [];
         $this->payload($response, $member, $result[$payload]);
     } else {
         // Streaming data is just the stream from the response body.
         $result[$payload] = $response->getBody();
     }
 }
 protected function format_structure(StructureShape $shape, array $value, $prefix, &$query)
 {
     if ($prefix) {
         $prefix .= '.';
     }
     foreach ($value as $k => $v) {
         if ($shape->hasMember($k)) {
             $member = $shape->getMember($k);
             $this->format($member, $v, $prefix . $this->queryName($member, $k), $query);
         }
     }
 }
 private function applyPayload(StructureShape $input, $name, array $args, array &$opts)
 {
     if (!isset($args[$name])) {
         return;
     }
     $m = $input->getMember($name);
     if ($m['streaming'] || ($m['type'] == 'string' || $m['type'] == 'blob')) {
         // Streaming bodies or payloads that are strings are
         // always just a stream of data.
         $opts['body'] = Psr7\stream_for($args[$name]);
         return;
     }
     $this->payload($m, $args[$name], $opts);
 }
Пример #5
0
 private function getStructureMembers(StructureShape $shape, array $value)
 {
     $members = [];
     foreach ($value as $k => $v) {
         if ($v !== null && $shape->hasMember($k)) {
             $definition = ['member' => $shape->getMember($k), 'value' => $v];
             if ($definition['member']['xmlAttribute']) {
                 // array_unshift_associative
                 $members = [$k => $definition] + $members;
             } else {
                 $members[$k] = $definition;
             }
         }
     }
     return $members;
 }
Пример #6
0
 private function check_structure(StructureShape $shape, $value)
 {
     if (!$this->checkAssociativeArray($value)) {
         return;
     }
     if ($shape['required']) {
         foreach ($shape['required'] as $req) {
             if (!isset($value[$req])) {
                 $this->path[] = $req;
                 $this->addError('is missing and is a required parameter');
                 array_pop($this->path);
             }
         }
     }
     foreach ($value as $name => $v) {
         if ($shape->hasMember($name)) {
             $this->path[] = $name;
             $this->dispatch($shape->getMember($name), isset($value[$name]) ? $value[$name] : null);
             array_pop($this->path);
         }
     }
 }
Пример #7
0
 private function applyPayload(RequestInterface $request, StructureShape $input, $name, array $args)
 {
     if (!isset($args[$name])) {
         return;
     }
     $m = $input->getMember($name);
     if ($m['streaming'] || ($m['type'] == 'string' || $m['type'] == 'blob')) {
         // Streaming bodies or payloads that are strings are
         // always just a stream of data.
         $request->setBody(Stream::factory($args[$name]));
     } else {
         $this->payload($request, $m, $args[$name]);
     }
 }