示例#1
0
 public function updateSportGroup(SportGroup $g)
 {
     if ($g == null) {
         throw new Exceptions\NullPointerException("Argument SportGroup cannot be null", 0);
     }
     try {
         $this->entityManager->beginTransaction();
         $dbGroup = $this->getSportGroup($g->getId(), false);
         if ($dbGroup !== null) {
             $dbGroup->fromArray($g->toArray());
             $this->groupParentHandle($dbGroup);
             $this->groupSportTypeHandle($dbGroup);
             $this->entityManager->merge($dbGroup);
             $this->entityManager->flush();
         }
         $this->entityManager->commit();
         $this->invalidateEntityCache($dbGroup);
         $this->onUpdate(clone $dbGroup);
     } catch (DuplicateEntryException $ex) {
         $this->logWarning($ex);
         throw new Exceptions\DuplicateEntryException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     } catch (Exception $ex) {
         $this->logError($ex->getMessage());
         throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     }
 }