Example #1
0
 /**
  * @Route("/round/{round}", name="admin_round", defaults={"round" = null})
  * @Template()
  */
 public function roundAction(Request $request, Round $round = null)
 {
     $this->checkIp($request);
     // new round defining
     if (!$round) {
         $round = new Round();
         if (!($currentRound = $this->roundRepo->findOneBy(['started' => true, 'finished' => false]))) {
             // first round auto start
             $roundId = 1;
         } else {
             $lastRound = $this->roundRepo->findOneBy([], ['id' => 'desc']);
             $roundId = $lastRound->getId() + 1;
         }
     } else {
         $roundId = $round->getId();
     }
     $form = $this->createForm(new RoundType(), $round);
     if ($request->isMethod('post')) {
         $form->submit($request);
         if ($form->isValid()) {
             if ($roundId == 1) {
                 $round->setStarted(true);
             }
             $this->em->persist($round);
             $this->em->flush();
             $this->roundManager->defineWalletAccount($round);
             return $this->redirect($this->generateUrl('admin'));
         }
     }
     return $this->render('AppBundle:Admin:round.html.twig', ['round' => $round, 'roundId' => $roundId, 'form' => $form->createView()]);
 }
 private function checkRoundEnd()
 {
     $time1 = new \DateTime();
     $time1->modify('-' . $this->round->getRoundTime() . ' hours');
     if ($this->round->getRoundTimeType() == Round::ROUND_TIME_TYPE_LAST_DEPOSIT) {
         $time2 = $this->round->getStats()->getLastDeposit();
     } else {
         $time2 = $this->round->getStats()->getLastPayout();
     }
     if ($time2 && $time1 > $time2) {
         $this->writeln('Round finished');
         $this->payoutManager->realiseRoundEndPayouts();
         $this->roundManager->startNextRound();
     } else {
         $this->writeln('Round not finished');
     }
 }