/** * @Route("/stages/get-fixtures", name="download-fixtures") * */ public function indexAction(Request $request) { $form = $this->createForm(FixtureType::class); $form->handleRequest($request); if ($form->isValid()) { $stage = $form->get('stage')->getData(); $sm = new SubscriptionManager($this->get('app.whoscored'), $this->getDoctrine()->getManager()); $start = strtotime($form->get('startweek')->getData()); $end = strtotime($form->get('endweek')->getData()); $d = $start; $count = 0; while ($d <= $end) { try { $result = $sm->getFixtures($stage, date('o\\WW', $d)); $count += $result; } catch (\Exception $e) { dump($e); } $d += 60 * 60 * 24 * 7; } $this->addFlash('notice', 'Downloaded fixtures from Stage ' . $stage->getName() . ' with WhoScored ID ' . $stage->getWsId() . '. ' . $count . ' matches saved.'); return $this->redirectToRoute('homepage'); } return $this->render('subscription/add_fixtures.html.twig', array('form' => $form->createView())); }