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.
|
|
<?php
namespace Zitec\RuleEngineBundle\Command;
use Symfony\Component\Console\Command\Command as ContainerAwareCommand;;use Symfony\Component\Console\Input\InputArgument;use Symfony\Component\Console\Input\InputInterface;use Symfony\Component\Console\Output\OutputInterface;use Doctrine\ORM\EntityManagerInterface;use App\Entity\Calendario;use DateTime;use App\Kernel;
class FixEventDatesCommand extends ContainerAwareCommand{ private $em; private $eventos=[];
public function __construct(EntityManagerInterface $em) { parent::__construct(); $this->em = $em;
} /** * {@inheritdoc} */ public function configure(): void { $this->setName('zitec:calendar:fixevents');
$this->setDescription( 'Fix Events Dates' ); } /** * {@inheritdoc} */ public function execute(InputInterface $input, OutputInterface $output): int {
$this->eventos = $this->em->getRepository('App:Calendario')->getByDifferentDates(); foreach ($this->eventos as $evento){ $fechainicio=$evento->getFechaFin(); $titulo=$evento->getTitulo(); $evento->setTitulo($titulo.': Start Date'); $evento->setFechaFin($evento->getFechaInicio()); $this->em->persist($evento); $nuevoEvento=new Calendario(); $nuevoEvento->setTitulo($titulo.': End Date'); $nuevoEvento->setFechaInicio($fechainicio); $nuevoEvento->setFechaFin($fechainicio); $nuevoEvento->setUser($evento->getUser()); $nuevoEvento->setProceso($evento->getProceso()); $this->em->persist($nuevoEvento); } $this->em->flush(); exit(0); }
}
|