|
@@ -0,0 +1,48 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace AppBundle\Command;
|
|
|
+
|
|
|
+use Doctrine\ORM\EntityManagerInterface;
|
|
|
+use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
|
|
+use Symfony\Component\Console\Input\InputArgument;
|
|
|
+use Symfony\Component\Console\Input\InputInterface;
|
|
|
+use Symfony\Component\Console\Output\OutputInterface;
|
|
|
+use Symfony\Component\Console\Question\ConfirmationQuestion;
|
|
|
+
|
|
|
+class AppUsersActivateCommand extends ContainerAwareCommand
|
|
|
+{
|
|
|
+ private $em;
|
|
|
+
|
|
|
+ public function __construct(EntityManagerInterface $em)
|
|
|
+ {
|
|
|
+ $this->em = $em;
|
|
|
+ parent::__construct();
|
|
|
+ }
|
|
|
+
|
|
|
+ protected function configure()
|
|
|
+ {
|
|
|
+ $this
|
|
|
+ ->setName('app:users:activate')
|
|
|
+ ->setDescription('Activer tous les users')
|
|
|
+ ;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected function execute(InputInterface $input, OutputInterface $output)
|
|
|
+ {
|
|
|
+ $helper = $this->getHelper('question');
|
|
|
+ $question = new ConfirmationQuestion('Activer tous les utilisateurs ?', false);
|
|
|
+ if (!$helper->ask($input, $output, $question))
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $users = $this->em->getRepository('AppBundle:User')->findAll();
|
|
|
+ foreach ($users as $user)
|
|
|
+ {
|
|
|
+ $user->setActivated(true);
|
|
|
+ }
|
|
|
+ $this->em->flush();
|
|
|
+
|
|
|
+ $output->writeln('Les utilisateurs sont activés');
|
|
|
+ }
|
|
|
+
|
|
|
+}
|