Exemplo n.º 1
0
 private function check_map(MapShape $shape, $value)
 {
     if (!$this->checkAssociativeArray($value)) {
         return;
     }
     $values = $shape->getValue();
     foreach ($value as $key => $v) {
         $this->path[] = $key;
         $this->dispatch($values, $v);
         array_pop($this->path);
     }
 }
 protected function format_map(MapShape $shape, array $value, $prefix, array &$query)
 {
     $vals = $shape->getValue();
     $keys = $shape->getKey();
     if (!$this->isFlat($shape)) {
         $prefix .= '.entry';
     }
     $i = 0;
     $keyName = '%s.%d.' . $this->queryName($keys, 'key');
     $valueName = '%s.%s.' . $this->queryName($vals, 'value');
     foreach ($value as $k => $v) {
         $i++;
         $this->format($keys, $k, sprintf($keyName, $prefix, $i), $query);
         $this->format($vals, $v, sprintf($valueName, $prefix, $i), $query);
     }
 }
Exemplo n.º 3
0
 private function parse_map(MapShape $shape, \SimpleXMLElement $value)
 {
     $target = [];
     if (!$shape['flattened']) {
         $value = $value->entry;
     }
     $mapKey = $shape->getKey();
     $mapValue = $shape->getValue();
     $keyName = $shape->getKey()['locationName'] ?: 'key';
     $valueName = $shape->getValue()['locationName'] ?: 'value';
     foreach ($value as $node) {
         $key = $this->dispatch($mapKey, $node->{$keyName});
         $value = $this->dispatch($mapValue, $node->{$valueName});
         $target[$key] = $value;
     }
     return $target;
 }
Exemplo n.º 4
0
 private function add_map(MapShape $shape, $name, array $value, XMLWriter $xml)
 {
     $xmlEntry = $shape['flattened'] ? $shape['locationName'] : 'entry';
     $xmlKey = $shape->getKey()['locationName'] ?: 'key';
     $xmlValue = $shape->getValue()['locationName'] ?: 'value';
     $this->startElement($shape, $name, $xml);
     foreach ($value as $key => $v) {
         $this->startElement($shape, $xmlEntry, $xml);
         $this->format($shape->getKey(), $xmlKey, $key, $xml);
         $this->format($shape->getValue(), $xmlValue, $v, $xml);
         $xml->endElement();
     }
     $xml->endElement();
 }