Esempio n. 1
0
 protected function save($id, $values)
 {
     if ($id) {
         if ($entity = $this->getItem($id)) {
             Doctrine::setValues($entity, $values);
         } else {
             throw new \Exception('Entity: ' . $this->entityClassName . ' with id=' . $id . ' not found');
         }
     } else {
         $entity = new $this->entityClassName();
         Doctrine::setValues($entity, $values);
     }
     $em = $this->getEntityManager();
     $em->persist($entity);
     $em->flush();
     return $entity;
 }