Browse Source

Command Refresh Embeds: Ajout de l'option sites.

bastien 13 years ago
parent
commit
eb016a2b7c
1 changed files with 27 additions and 3 deletions
  1. 27 3
      src/Muzich/CoreBundle/Command/RefreshEmbedsCommand.php

+ 27 - 3
src/Muzich/CoreBundle/Command/RefreshEmbedsCommand.php View File

20
       // Dans l'avenir on pourra préciser:
20
       // Dans l'avenir on pourra préciser:
21
       // - le type
21
       // - le type
22
       // - l'élément
22
       // - l'élément
23
-//      ->addArgument('name', InputArgument::OPTIONAL, 'Who do you want to greet?')
23
+      ->addOption('sites', null, InputOption::VALUE_REQUIRED, 'Liste exhaustive des site a traiter')
24
+//      ->addArgument('sites', InputArgument::OPTIONAL, 'Liste exhaustive des site a traiter')
24
 //      ->addOption('yell', null, InputOption::VALUE_NONE, 'If set, the task will yell in uppercase letters')
25
 //      ->addOption('yell', null, InputOption::VALUE_NONE, 'If set, the task will yell in uppercase letters')
25
     ;
26
     ;
26
   }
27
   }
33
     $output->writeln('#');
34
     $output->writeln('#');
34
     $output->writeln('## Script de mise a jour des code embeds ##');
35
     $output->writeln('## Script de mise a jour des code embeds ##');
35
     $output->writeln('#');
36
     $output->writeln('#');
37
+
38
+    $filter_sites = array();
39
+    if (($sites = $input->getOption('sites')))
40
+    {
41
+      foreach (explode(',', $sites) as $site)
42
+      {
43
+        $filter_sites[] = trim($site);
44
+      }
45
+    }
46
+    
36
     
47
     
37
-    // On récupère tout les éléments
38
-    $elements = $em->getRepository('MuzichCoreBundle:Element')->findAll();
48
+    // On récupère les éléments
49
+    if (count($filter_sites))
50
+    {
51
+      $elements = $em->createQuery(
52
+        "SELECT e FROM MuzichCoreBundle:Element e "
53
+        . " WHERE e.type IN (:types)"
54
+      )->setParameter('types', $filter_sites)
55
+       ->getResult()      
56
+      ;
57
+      $output->writeln('<comment>Utilisation de filtre par site ('.$input->getOption('sites').')</comment>');
58
+    }
59
+    else
60
+    {
61
+      $elements = $em->getRepository('MuzichCoreBundle:Element')->findAll();
62
+    }
39
     
63
     
40
     $output->writeln('<info>Nombre d\'éléments a traiter: '.count($elements).'</info>');
64
     $output->writeln('<info>Nombre d\'éléments a traiter: '.count($elements).'</info>');
41
     $output->writeln('<info>Début du traitement ...</info>');
65
     $output->writeln('<info>Début du traitement ...</info>');