예제 #1
0
 public function updatePayment(Payment $p)
 {
     if ($p === NULL) {
         throw new Exceptions\NullPointerException("Argument Payment was null.");
     }
     try {
         $this->entityManager->beginTransaction();
         $paymentDb = $this->paymentDao->find($p->getId(), false);
         if ($paymentDb !== null) {
             $paymentDb->fromArray($p->toArray());
             $this->paymentOwnerTypeHandle($paymentDb);
             $this->paymentSeasonTypeHandle($paymentDb);
             $this->paymentEditorTypeHandle($paymentDb);
             $this->paymentDao->save($paymentDb);
             $this->invalidateEntityCache($paymentDb);
             $this->onUpdate($paymentDb);
         }
         $this->entityManager->commit();
     } catch (DuplicateEntryException $ex) {
         $this->entityManager->rollback();
         $this->logWarning($ex);
         throw new Exceptions\DuplicateEntryException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     } catch (\Exception $ex) {
         $this->entityManager->rollback();
         $this->logError($ex->getMessage());
         throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     }
 }