use murph entity manager instead of doctrine entity manager

This commit is contained in:
Simon Vieille 2025-02-05 14:10:50 +01:00
commit c05a02d924

View file

@ -10,47 +10,45 @@ use Symfony\Component\Console\Output\OutputInterface;
class UpdateEntityInterventionCommand extends Command
{
private $em;
public function __construct(
protected EntityManager $entityManager,
protected InterventionRepositoryQuery $interventionQuery
)
{
parent::__construct();
}
private $interventionQuery;
/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('update:entity:intervention')
->setDescription('Update entity intervention between 2 migrations. Adding field establishmentGroup and removingEstablishmentGroups')
->setHelp('')
;
}
public function __construct(EntityManager $entityManager, InterventionRepositoryQuery $interventionQuery)
{
parent::__construct();
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$interventions = $this->interventionQuery->create()->find();
$this->em = $entityManager;
$this->interventionQuery = $interventionQuery;
}
foreach ($interventions as $intervention) {
if (null !== $intervention->getEstablishmentGroupsOld()->first()) {
$intervention->setEstablishmentGroup($intervention->getEstablishmentGroupsOld()[0]);
/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('update:entity:intervention')
->setDescription('Update entity intervention between 2 migrations. Adding field establishmentGroup and removingEstablishmentGroups')
->setHelp('');
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$interventions = $this->interventionQuery->create()->find();
foreach ($interventions as $intervention){
if($intervention->getEstablishmentGroupsOld()->first()!==null) {
$intervention->setEstablishmentGroup($intervention->getEstablishmentGroupsOld()[0]);
$this->em->update($intervention);
}
$this->entityManager->update($intervention, flush: false);
}
$this->em->flush();
$output->writeln('Les entités interventions ont été mis à jour. Exécuter de nouveau la migration suivante. ');
return Command::SUCCESS;
}
$this->entityManager->flush();
$output->writeln('Les entités interventions ont été mis à jour. Exécuter de nouveau la migration suivante. ');
return Command::SUCCESS;
}
}