/**
* Method for saving a feedback
*
* @param \Newscoop\Entity\Feedback $entity
* @param array $values
* @return Feedback \Newscoop\Entity\Feedback
*/
public function save(Feedback $entity, $values)
{
// get the entity manager
$em = $this->getEntityManager();
if (array_key_exists('user', $values)) {
$user = $em->getReference('Newscoop\\Entity\\User', $values['user']);
$entity->setUser($user);
}
if (!empty($values['publication'])) {
$publication = $em->getReference('Newscoop\\Entity\\Publication', $values['publication']);
$entity->setPublication($publication);
}
if (!empty($values['section'])) {
$section = $em->getReference('Newscoop\\Entity\\Section', $values['section']);
$entity->setSection($section);
}
if (!empty($values['language']) && !empty($values['article'])) {
$article = $em->getReference('Newscoop\\Entity\\Article', array('language' => $values['language'], 'number' => $values['article']));
$entity->setArticle($article);
}
if (isset($values['subject'])) {
$entity->setSubject($values['subject']);
}
if (isset($values['message'])) {
$entity->setMessage($values['message']);
}
if (isset($values['url'])) {
$entity->setUrl($values['url']);
}
if (isset($values['time_created'])) {
$entity->setTimeCreated($values['time_created']);
}
if (isset($values['status'])) {
$entity->setStatus($values['status']);
}
if (isset($values['attachment_type'])) {
$entity->setAttachmentType($values['attachment_type']);
}
if (isset($values['attachment_id'])) {
$entity->setAttachmentId($values['attachment_id']);
}
$em->persist($entity);
return $entity;
}