protected function UpdateProcessor::parseXml in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/update/src/UpdateProcessor.php \Drupal\update\UpdateProcessor::parseXml()
Parses the XML of the Drupal release history info files.
Parameters
string $raw_xml: A raw XML string of available release data for a given project.
Return value
array Array of parsed data about releases for a given project, or NULL if there was an error parsing the string.
1 call to UpdateProcessor::parseXml()
- UpdateProcessor::processFetchTask in core/
modules/ update/ src/ UpdateProcessor.php - Processes a task to fetch available update data for a single project.
File
- core/
modules/ update/ src/ UpdateProcessor.php, line 212 - Contains \Drupal\update\UpdateProcessor.
Class
- UpdateProcessor
- Process project update information.
Namespace
Drupal\updateCode
protected function parseXml($raw_xml) {
try {
$xml = new \SimpleXMLElement($raw_xml);
} catch (\Exception $e) {
// SimpleXMLElement::__construct produces an E_WARNING error message for
// each error found in the XML data and throws an exception if errors
// were detected. Catch any exception and return failure (NULL).
return NULL;
}
// If there is no valid project data, the XML is invalid, so return failure.
if (!isset($xml->short_name)) {
return NULL;
}
$data = array();
foreach ($xml as $k => $v) {
$data[$k] = (string) $v;
}
$data['releases'] = array();
if (isset($xml->releases)) {
foreach ($xml->releases
->children() as $release) {
$version = (string) $release->version;
$data['releases'][$version] = array();
foreach ($release
->children() as $k => $v) {
$data['releases'][$version][$k] = (string) $v;
}
$data['releases'][$version]['terms'] = array();
if ($release->terms) {
foreach ($release->terms
->children() as $term) {
if (!isset($data['releases'][$version]['terms'][(string) $term->name])) {
$data['releases'][$version]['terms'][(string) $term->name] = array();
}
$data['releases'][$version]['terms'][(string) $term->name][] = (string) $term->value;
}
}
}
}
return $data;
}