Ejemplo n.º 1
0
 /**
  * @Template()
  *
  * http://localhost/WindServer/web/app_dev.php/admin/BO/ajax/maree/get/1
  */
 public function getMareePrevAction($id = null)
 {
     $em = $this->container->get('doctrine.orm.entity_manager');
     if (isset($id) && $id != -1) {
         $spot = $em->find('LaPoizWindBundle:Spot', $id);
         if (!$spot) {
             return $this->container->get('templating')->renderResponse('LaPoizWindBundle:BackOffice:errorPage.html.twig', array('errMessage' => "No spot find !"));
         }
         //$prevMaree=MareeGetData::getMaree($spot->getMareeURL());
         $prevMaree = MareeGetData::getMareeForXDays($spot->getMareeURL(), 10, new NullOutput());
         return $this->render('LaPoizWindBundle:BackOffice/Spot/Ajax/Maree:prevMaree.html.twig', array('prevMaree' => $prevMaree, 'mareeURL' => $spot->getMareeURL(), 'spot' => $spot));
     } else {
         return $this->container->get('templating')->renderResponse('LaPoizWindBundle:BackOffice:errorPage.html.twig', array('errMessage' => "Miss id of dataWindPrev... !"));
     }
 }
Ejemplo n.º 2
0
 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);
         }
     }
 }