Command/QueryWikipediaCommand.php
changeset 68 e7384fb35f7a
parent 67 989d9e117586
equal deleted inserted replaced
67:989d9e117586 68:e7384fb35f7a
    22 {
    22 {
    23 
    23 
    24     private function processTag($tag, $em)
    24     private function processTag($tag, $em)
    25     {
    25     {
    26         $tag_label_normalized = WikiTagUtils::normalizeTag($tag->getLabel());
    26         $tag_label_normalized = WikiTagUtils::normalizeTag($tag->getLabel());
    27         $wp_response = WikiTagUtils::getWikipediaInfo($tag_label_normalized, null, $this->getContainer()->getParameter('wiki_tag.ignore_wikipedia_error'));
    27         $wp_response = WikiTagUtils::getWikipediaInfo($tag_label_normalized, null, $this->getContainer()->getParameter('wiki_tag.ignore_wikipedia_error'), $this->getContainer()->get('logger'));
    28         
    28         
    29         $tag->setWikipediaInfo($wp_response);
    29         $tag->setWikipediaInfo($wp_response);
    30         
    30         
    31         // Save datas.
    31         // Save datas.
    32         $em->persist($tag);
    32         $em->persist($tag);
    43             ->setDescription('Query wikipedia for tags.')
    43             ->setDescription('Query wikipedia for tags.')
    44             ->addOption("force","f",InputOption::VALUE_NONE, "Force processing tags, will ask no confirmation")
    44             ->addOption("force","f",InputOption::VALUE_NONE, "Force processing tags, will ask no confirmation")
    45             ->addOption("all","a",InputOption::VALUE_NONE, "Search all tags")
    45             ->addOption("all","a",InputOption::VALUE_NONE, "Search all tags")
    46             ->addOption("null","n",InputOption::VALUE_NONE, "Treat only non processed tags")
    46             ->addOption("null","n",InputOption::VALUE_NONE, "Treat only non processed tags")
    47             ->addOption("redirection",null,InputOption::VALUE_NONE, "Treat redirections")
    47             ->addOption("redirection",null,InputOption::VALUE_NONE, "Treat redirections")
    48             ->addOption("random","r",InputOption::VALUE_NONE, "randomize query on tags")
       
    49             ->addOption("site","S",InputOption::VALUE_OPTIONAL, "the url for the wikipedia site", "http://fr.wikipedia.org/w/api.php")
    48             ->addOption("site","S",InputOption::VALUE_OPTIONAL, "the url for the wikipedia site", "http://fr.wikipedia.org/w/api.php")
    50             ->addOption("limit","l",InputOption::VALUE_OPTIONAL, "number of tag to process", -1)
    49             ->addOption("limit","l",InputOption::VALUE_OPTIONAL, "number of tag to process", -1)
    51             ->addOption("start",null,InputOption::VALUE_OPTIONAL, "number of tag to ignore", 0);
    50             ->addOption("start",null,InputOption::VALUE_OPTIONAL, "number of tag to ignore", 0);
    52     }
    51     }
    53 
    52 
    54     protected function execute(InputInterface $input, OutputInterface $output)
    53     protected function execute(InputInterface $input, OutputInterface $output)
    55     {
    54     {
    56         
    55         
    57         $force = $input->getOption('force');
    56         $force = $input->getOption('force');
    58         $all = $input->getOption('all');
    57         $all = $input->getOption('all');
    59         $random = $input->getOption('random');
       
    60         $redirection = $input->getOption('redirection');
    58         $redirection = $input->getOption('redirection');
    61         $site = $input->getOption('site');
    59         $site = $input->getOption('site');
    62         $limit = intval($input->getOption('limit'));
    60         $limit = intval($input->getOption('limit'));
    63         $start = intval($input->getOption('start'));
    61         $start = intval($input->getOption('start'));
    64         $null = $input->getOption('null');
    62         $null = $input->getOption('null');