|
@@ -20,7 +20,8 @@ class RefreshEmbedsCommand extends ContainerAwareCommand
|
20
|
20
|
// Dans l'avenir on pourra préciser:
|
21
|
21
|
// - le type
|
22
|
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
|
25
|
// ->addOption('yell', null, InputOption::VALUE_NONE, 'If set, the task will yell in uppercase letters')
|
25
|
26
|
;
|
26
|
27
|
}
|
|
@@ -33,9 +34,32 @@ class RefreshEmbedsCommand extends ContainerAwareCommand
|
33
|
34
|
$output->writeln('#');
|
34
|
35
|
$output->writeln('## Script de mise a jour des code embeds ##');
|
35
|
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
|
64
|
$output->writeln('<info>Nombre d\'éléments a traiter: '.count($elements).'</info>');
|
41
|
65
|
$output->writeln('<info>Début du traitement ...</info>');
|