private function importTournament(Tournament $source_tournament, Tournament $tournament) { $em = $this->getDoctrine()->getEntityManager(); $em->beginTransaction(); try { $tournament->setKey(uniqid()); $tournament->setEdition($source_tournament->getEdition()); $tournament->setName($source_tournament->getName() . ' ' . $this->get('translator')->trans('FORM.TOURNAMENTIMPORT.COPY', array(), 'admin')); $tournament->setDescription($source_tournament->getDescription()); $tournament->getOption()->setDrr($source_tournament->getOption()->isDrr()); $tournament->getOption()->setStrategy($source_tournament->getOption()->getStrategy()); $tournament->getOption()->setWpoints($source_tournament->getOption()->getWpoints()); $tournament->getOption()->setTpoints($source_tournament->getOption()->getTpoints()); $tournament->getOption()->setLpoints($source_tournament->getOption()->getLpoints()); $tournament->getOption()->setDscore($source_tournament->getOption()->getDscore()); $em->persist($tournament); $em->flush(); $this->importSites($source_tournament, $tournament); $em->commit(); } catch (Exception $e) { $em->rollBack(); throw $e; } }
private function checkForm($form, Tournament $tournament) { if ($form->isValid()) { if ($tournament->getName() == null || trim($tournament->getName()) == '') { $form->addError(new FormError($this->get('translator')->trans('FORM.TOURNAMENT.NONAME', array(), 'admin'))); return false; } if ($tournament->getKey() == null || trim($tournament->getKey()) == '') { $form->addError(new FormError($this->get('translator')->trans('FORM.TOURNAMENT.NOKEY', array(), 'admin'))); return false; } if ($tournament->getEdition() == null || trim($tournament->getEdition()) == '') { $form->addError(new FormError($this->get('translator')->trans('FORM.TOURNAMENT.NOEDITION', array(), 'admin'))); return false; } return true; } return false; }