protected function convertBlockToHash(Block $block)
{
$hash = array();
foreach ($block->getState() as $propName => $propValue) {
switch ($propName) {
case 'id':
case 'name':
case 'type':
case 'view':
case 'overflowId':
case 'customAttributes':
case 'action':
case 'rotation':
case 'zoneId':
if ($propValue !== null) {
$hash[$propName] = $propValue;
}
break;
case 'attributes':
if ($propValue !== null && $propValue !== array()) {
$hash['attributes'] = $propValue;
}
break;
case 'items':
foreach ($propValue as $item) {
$hash['items'][] = $this->convertItemToHash($item);
}
break;
}
}
return $hash;
}