I have a call that looks like the following:
$foo = $em->getRepository('MyBundle:Bar')->find($id);
I would like to be able to loop over all of the column/value pairs that get returned into $foo. I have found that in most cases the following call gets me the information I want:
public function getEntityColumnValues($entity, $em){
$cols = $em->getClassMetadata(get_class($entity))->getColumnNames();
$values = array();
foreach($cols as $col){
$getter = 'get' . $this->underscoreToCamelCase($col, true);
$values[$col] = $entity->$getter();
}
return $values;
}
Sometimes, however, the entity contains some information that only exists as doctrine association mappings. That info ends out not being set in $values. Is there a way to loop over the values that get set in $foo without getting the class metadata via the getEntityColumnValues() function I have? Maybe there is a way I can enhance my function to get those mappings? Thanks.