|
@@ -0,0 +1,54 @@
|
|
1
|
+<?php
|
|
2
|
+
|
|
3
|
+namespace Muzich\CoreBundle\Command;
|
|
4
|
+
|
|
5
|
+use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
|
6
|
+use Symfony\Component\Console\Input\InputArgument;
|
|
7
|
+use Symfony\Component\Console\Input\InputInterface;
|
|
8
|
+use Symfony\Component\Console\Input\InputOption;
|
|
9
|
+use Symfony\Component\Console\Output\OutputInterface;
|
|
10
|
+
|
|
11
|
+use Muzich\CoreBundle\ElementFactory\ElementManager;
|
|
12
|
+
|
|
13
|
+class RefreshEmbedsCommand extends ContainerAwareCommand
|
|
14
|
+{
|
|
15
|
+ protected function configure()
|
|
16
|
+ {
|
|
17
|
+ $this
|
|
18
|
+ ->setName('elementengine:refresh-embeds')
|
|
19
|
+ ->setDescription('Actualise les embeds')
|
|
20
|
+ // Dans l'avenir on pourra préciser:
|
|
21
|
+ // - le type
|
|
22
|
+ // - l'élément
|
|
23
|
+// ->addArgument('name', InputArgument::OPTIONAL, 'Who do you want to greet?')
|
|
24
|
+// ->addOption('yell', null, InputOption::VALUE_NONE, 'If set, the task will yell in uppercase letters')
|
|
25
|
+ ;
|
|
26
|
+ }
|
|
27
|
+
|
|
28
|
+ protected function execute(InputInterface $input, OutputInterface $output)
|
|
29
|
+ {
|
|
30
|
+ $doctrine = $this->getContainer()->get('doctrine');
|
|
31
|
+ $em = $doctrine->getEntityManager();
|
|
32
|
+
|
|
33
|
+ $output->writeln('#');
|
|
34
|
+ $output->writeln('## Script de mise a jour des code embeds ##');
|
|
35
|
+ $output->writeln('#');
|
|
36
|
+
|
|
37
|
+ // On récupère tout les éléments
|
|
38
|
+ $elements = $em->getRepository('MuzichCoreBundle:Element')->findAll();
|
|
39
|
+
|
|
40
|
+ $output->writeln('<info>Nombre d\'éléments a traiter: '.count($elements).'</info>');
|
|
41
|
+ $output->writeln('<info>Début du traitement ...</info>');
|
|
42
|
+
|
|
43
|
+ foreach ($elements as $element)
|
|
44
|
+ {
|
|
45
|
+ $factory = new ElementManager($element, $em, $this->getContainer());
|
|
46
|
+ $factory->proceedExtraFields();
|
|
47
|
+ $em->persist($element);
|
|
48
|
+ }
|
|
49
|
+
|
|
50
|
+ $output->writeln('<info>Traitement terminé, enregistrement en base ...</info>');
|
|
51
|
+ $em->flush();
|
|
52
|
+ $output->writeln('<info>Enregistrement terminé !</info>');
|
|
53
|
+ }
|
|
54
|
+}
|