/** * @Template() * Sauvegarde les prévisions de marée en prenant en compte ce qui existe déjà dans la BD */ public function mareeSaveAction($id) { $em = $this->container->get('doctrine.orm.entity_manager'); $spots = $em->getRepository('LaPoizWindBundle:Spot')->findAll(); $spot = $em->find('LaPoizWindBundle:Spot', $id); $form = $this->createForm('testGetMaree', $spots); if (!$spot) { return $this->container->get('templating')->renderResponse('LaPoizWindBundle:Default:errorBlock.html.twig', array('errMessage' => "No spot find !")); } $mareeURL = $spot->getParameter()->getMareeURL(); if (!empty($mareeURL)) { $prevMaree = MareeGetData::getMaree($mareeURL); MareeGetData::saveMaree($spot, $prevMaree, $em, new NullOutput()); } $mareeDateDB = $em->getRepository('LaPoizWindBundle:MareeDate')->findLastPrev(10, $spot); return $this->container->get('templating')->renderResponse('LaPoizWindBundle:BackOffice/Test:maree.html.twig', array('listSpot' => $spots, 'spot' => $spot, 'form' => $form->createView(), 'mareeURL' => $mareeURL, 'prevMaree' => $prevMaree, 'mareeDateDB' => $mareeDateDB)); }
protected function execute(InputInterface $input, OutputInterface $output) { // get list of URL $em = $this->getContainer()->get('doctrine.orm.entity_manager'); $dataWindPrevList = $em->getRepository('LaPoizWindBundle:DataWindPrev')->findAll(); foreach ($dataWindPrevList as $dataWindPrev) { try { GetDataCommand::getDataFromDataWindPrev($dataWindPrev, $output, $em); } catch (\Exception $e) { $output->writeln('<error>' . $e->getMessage() . '</error>'); } } // Get Marée $spotList = $em->getRepository('LaPoizWindBundle:Spot')->findAll(); $output->writeln('<info>************** GET MAREE ****************</info>'); foreach ($spotList as $spot) { if ($spot->getMareeURL() != null) { //$prevMaree = MareeGetData::getMaree($spot->getMareeURL()); $prevMaree = MareeGetData::getMareeForXDays($spot->getMareeURL(), 10, $output); MareeGetData::saveMaree($spot, $prevMaree, $em, $output); } } }
/** * @Template() * Sauvegarde les prévisions de marée en prenant en compte ce qui existe déjà dans la BD * http://localhost/Wind/web/app_dev.php/admin/BO/ajax/spot/maree/save/1 */ public function mareeSaveAction($id) { $em = $this->container->get('doctrine.orm.entity_manager'); $spot = $em->find('LaPoizWindBundle:Spot', $id); if (!$spot) { return $this->container->get('templating')->renderResponse('LaPoizWindBundle:Default:errorBlock.html.twig', array('errMessage' => "Spot not find !")); } $mareeURL = $spot->getMareeURL(); if (!empty($mareeURL)) { $prevMaree = MareeGetData::getMaree($mareeURL); MareeGetData::saveMaree($spot, $prevMaree, $em, new NullOutput()); } $mareeDateDB = $em->getRepository('LaPoizWindBundle:MareeDate')->findLastPrev(10, $spot); return $this->container->get('templating')->renderResponse('LaPoizWindBundle:BackOffice/Spot/Ajax/Maree:mareeSaveResult.html.twig', array('mareeDateDB' => $mareeDateDB, 'spot' => $spot, 'message' => "", 'saveSuccess' => true)); }