protected function restoreZoneFromXml(DOMElement $node)
{
$zoneId = null;
$zoneIdentifier = null;
$action = null;
$blocks = array();
$attributes = array();
if ($node->hasAttributes()) {
foreach ($node->attributes as $attr) {
switch ($attr->name) {
case 'id':
// Stored Id has following format : id_<zoneId>, so extract <zoneId>
$zoneId = substr($attr->value, strpos($attr->value, '_') + 1);
break;
case 'action':
$action = $attr->value;
break;
default:
$attributes[$attr->name] = $attr->value;
}
}
}
foreach ($node->childNodes as $node) {
if ($node->nodeType !== XML_ELEMENT_NODE) {
continue;
}
switch ($node->nodeName) {
case 'block':
$block = $this->restoreBlockFromXml($node);
$blocks[] = $block;
break;
case 'zone_identifier':
$zoneIdentifier = $node->nodeValue;
break;
default:
$attributes[$node->nodeName] = $node->nodeValue;
}
}
return new Parts\Zone(array('id' => $zoneId, 'identifier' => $zoneIdentifier, 'attributes' => $attributes, 'action' => $action, 'blocks' => $blocks));
}