mirror of
https://github.com/guzzle/guzzle.git
synced 2025-02-26 19:15:10 +01:00
Breaking XML attribute parsing into its own method
This commit is contained in:
parent
1ec658b251
commit
71d631680f
@ -117,13 +117,7 @@ class XmlVisitor extends AbstractResponseVisitor
|
|||||||
$name = $property->getName();
|
$name = $property->getName();
|
||||||
$sentAs = $property->getWireName();
|
$sentAs = $property->getWireName();
|
||||||
if ($property->getData('xmlAttribute')) {
|
if ($property->getData('xmlAttribute')) {
|
||||||
if (isset($value['@attributes'][$sentAs])) {
|
$this->processXmlAttribute($property, $value);
|
||||||
$value[$name] = $value['@attributes'][$sentAs];
|
|
||||||
unset($value['@attributes'][$sentAs]);
|
|
||||||
if (empty($value['@attributes'])) {
|
|
||||||
unset($value['@attributes']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} elseif (isset($value[$sentAs])) {
|
} elseif (isset($value[$sentAs])) {
|
||||||
$this->recursiveProcess($property, $value[$sentAs]);
|
$this->recursiveProcess($property, $value[$sentAs]);
|
||||||
if ($name != $sentAs) {
|
if ($name != $sentAs) {
|
||||||
@ -137,4 +131,22 @@ class XmlVisitor extends AbstractResponseVisitor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process an XML attribute property
|
||||||
|
*
|
||||||
|
* @param Parameter $property Property to process
|
||||||
|
* @param array $value Value to process and update
|
||||||
|
*/
|
||||||
|
protected function processXmlAttribute(Parameter $property, array &$value)
|
||||||
|
{
|
||||||
|
$sentAs = $property->getWireName();
|
||||||
|
if (isset($value['@attributes'][$sentAs])) {
|
||||||
|
$value[$property->getName()] = $value['@attributes'][$sentAs];
|
||||||
|
unset($value['@attributes'][$sentAs]);
|
||||||
|
if (empty($value['@attributes'])) {
|
||||||
|
unset($value['@attributes']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user