migrations/Version20221118120056.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use App\Entity\FunctionalEvaluation;
  5. use Doctrine\DBAL\Schema\Schema;
  6. use Doctrine\Migrations\AbstractMigration;
  7. use Doctrine\ORM\EntityManager;
  8. use Symfony\Component\DependencyInjection\ContainerAwareInterface;
  9. use Symfony\Component\DependencyInjection\ContainerInterface;
  10. final class Version20221118120056 extends AbstractMigration implements ContainerAwareInterface
  11. {
  12.     private EntityManager $em;
  13.     private ContainerInterface $container;
  14.     public function setContainer(ContainerInterface $container null)
  15.     {
  16.         $this->container $container;
  17.         $this->em $container->get('doctrine')->getManager();
  18.     }
  19.     public function getDescription(): string
  20.     {
  21.         return 'update functional Evaluation name';
  22.     }
  23.     public function up(Schema $schema): void
  24.     {
  25.     }
  26.     public function postUp(Schema $schema): void
  27.     {
  28.         $functionalEvaluation $this->em->getRepository(FunctionalEvaluation::class)->findOneBy(['name' => 'Gestion electronique des documents']);
  29.         if ($functionalEvaluation) {
  30.             $functionalEvaluation->setName('Gestion Ã©lectronique des documents');
  31.             $this->em->persist($functionalEvaluation);
  32.         }
  33.         $this->em->flush();
  34.     }
  35.     public function down(Schema $schema): void
  36.     {
  37.     }
  38. }