public function describe($entity)
{
$accessor = new PropertyAccessor();
$description = [];
switch ($this->em->getUnitOfWork()->getEntityState($entity)) {
case UnitOfWork::STATE_NEW:
$description["title"] = "Would create a new entity of type " . get_class($entity);
$cm = $this->em->getClassMetadata(get_class($entity));
foreach ($cm->getFieldNames() as $fieldName) {
$description["fields"][$fieldName] = $accessor->getValue($entity, $fieldName);
}
foreach ($cm->getAssociationNames() as $associationMapping) {
$foo = $accessor->getValue($entity, $associationMapping);
if ($foo !== null) {
$description["associations"][$associationMapping] = $foo->getId();
} else {
$description["error"] = "Would stop import because a mapping was not found";
}
}
break;
}
$descriptions[] = $description;
return $description;
}