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) { if ($dataWindPrev->getWebSite()->getNom() == WebsiteGetData::windFinderName) { GetDataCommand::getDataFromDataWindPrev($dataWindPrev, $output, $em); } } }
public static function getDataFromDataWindPrev(DataWindPrev $dataWindPrev, OutputInterface $output, EntityManager $em) { $output->write('<info>Spot ' . $dataWindPrev->getSpot()->getNom() . ' - </info>'); // get each web site $output->writeln('<info>site ' . $dataWindPrev->getWebSite()->getNom() . ' -> ' . $dataWindPrev->getUrl() . '</info>'); // Delete old value GetDataCommand::deleteOldPrevisionDate($dataWindPrev, $output, $em); // save data $websiteGetData = WebsiteGetData::getWebSiteObject($dataWindPrev); // return WindguruGetData or MeteoFranceGetData... depend of $dataWindPrev $data = $websiteGetData->getDataFromURL($dataWindPrev); // array($result,$chrono) $output->write('<info> get data: ' . $data[1] . '</info>'); $analyse = $websiteGetData->analyseDataFromPage($data[0], $dataWindPrev->getUrl()); // array($result,$chrono) $output->write('<info> analyse: ' . $analyse[1] . '</info>'); $transformData = $websiteGetData->transformDataFromTab($analyse[0]); // array($result,$chrono) $output->write('<info> transforme data: ' . $transformData[1] . '</info>'); $saveData = $websiteGetData->saveFromTransformData($transformData[0], $dataWindPrev, $em); // array(array $prevDate,$chrono) $output->writeln('<info> save data: ' . $saveData[1] . '</info>'); $output->writeln('<info>******************************</info>'); }