protected function execute(InputInterface $input, OutputInterface $output) { // get list of URL $em = $this->getContainer()->get('doctrine.orm.entity_manager'); // Get Marée $spotList = $em->getRepository('LaPoizWindBundle:Spot')->findAll(); $output->writeln('<info>************** DELETE MAREE ****************</info>'); foreach ($spotList as $spot) { if ($spot->getMareeURL() != null) { MareeGetData::deleteMaree($spot, $em, $output); } } }
/** * @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() * * http://localhost/Wind/web/app_dev.php/admin/BO/ajax/maree/{idURLInfoMaree}/forDay/{idDateURLInfoMaree} * dateMaree = 20150106 */ public function getMareeForDayAction($idURLInfoMaree = null, $idDateURLInfoMaree = null, Request $request) { // Récupere la page: http://maree.info/$idURLInfoMaree?d=$idDateURLInfoMaree // Parse avec ce qui est déjà fait dans core -> MareeGetData // envoie la hauteur marée haute et marée basse en JSON return new JsonResponse(MareeGetData::getHauteurMaree($idURLInfoMaree, $idDateURLInfoMaree)); }
static function getHauteurMaree($idURLInfoMaree, $idDateURLInfoMaree) { // Récupere la page: http://maree.info/$idURLInfoMaree?d=$idDateURLInfoMaree // dateMaree = 20150106 $url = "http://maree.info/" . $idURLInfoMaree . "?d=" . $idDateURLInfoMaree; return MareeGetData::getHauteurMareeFromURL($url); }