Licitator 1.0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.7 KiB

5 years ago
  1. <?php
  2. namespace Zitec\RuleEngineBundle\Command;
  3. use Symfony\Component\Console\Command\Command as ContainerAwareCommand;;
  4. use Symfony\Component\Console\Input\InputArgument;
  5. use Symfony\Component\Console\Input\InputInterface;
  6. use Symfony\Component\Console\Output\OutputInterface;
  7. use Doctrine\ORM\EntityManagerInterface;
  8. use App\Entity\Calendario;
  9. use DateTime;
  10. use App\Kernel;
  11. class FixEventDatesCommand extends ContainerAwareCommand
  12. {
  13. private $em;
  14. private $eventos=[];
  15. public function __construct(EntityManagerInterface $em)
  16. {
  17. parent::__construct();
  18. $this->em = $em;
  19. }
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function configure(): void
  24. {
  25. $this->setName('zitec:calendar:fixevents');
  26. $this->setDescription(
  27. 'Fix Events Dates'
  28. );
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function execute(InputInterface $input, OutputInterface $output): int
  34. {
  35. $this->eventos = $this->em->getRepository('App:Calendario')->getByDifferentDates();
  36. foreach ($this->eventos as $evento){
  37. $fechainicio=$evento->getFechaFin();
  38. $titulo=$evento->getTitulo();
  39. $evento->setTitulo($titulo.': Start Date');
  40. $evento->setFechaFin($evento->getFechaInicio());
  41. $this->em->persist($evento);
  42. $nuevoEvento=new Calendario();
  43. $nuevoEvento->setTitulo($titulo.': End Date');
  44. $nuevoEvento->setFechaInicio($fechainicio);
  45. $nuevoEvento->setFechaFin($fechainicio);
  46. $nuevoEvento->setUser($evento->getUser());
  47. $nuevoEvento->setProceso($evento->getProceso());
  48. $this->em->persist($nuevoEvento);
  49. }
  50. $this->em->flush();
  51. exit(0);
  52. }
  53. }