protected function addResultMapGroupBy($resultMap, $row, $parent, &$resultObject)
{
$group = $this->getResultMapGroupKey($resultMap, $row);
if (empty($parent)) {
$rootObject = array('object' => $resultObject, 'property' => null);
$this->_groupBy->add(null, $group, $rootObject);
}
foreach ($resultMap->getColumns() as $property) {
//set properties.
$this->setObjectProperty($resultMap, $property, $row, $resultObject);
$nested = $property->getResultMapping();
//nested property
if ($this->getManager()->getResultMaps()->contains($nested)) {
$nestedMap = $this->getManager()->getResultMap($nested);
$groupKey = $this->getResultMapGroupKey($nestedMap, $row);
//add the node reference first
if (empty($parent)) {
$this->_groupBy->add($group, $groupKey, '');
}
//get the nested result mapping value
$value = $this->fillResultMap($nested, $row, $groupKey);
//add it to the object tree graph
$groupObject = array('object' => $value, 'property' => $property->getProperty());
if (empty($parent)) {
$this->_groupBy->add($group, $groupKey, $groupObject);
} else {
$this->_groupBy->add($parent, $groupKey, $groupObject);
}
}
}
return $resultObject;
}