migrations/Version20240731130955DataUpdate.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use App\Entity\ActiveServices\Project;
  5. use App\Entity\ActiveServices\ProjectStatus;
  6. use App\Repository\ActiveServices\ProjectStatusRepository;
  7. use Doctrine\DBAL\Schema\Schema;
  8. use Doctrine\Migrations\AbstractMigration;
  9. use Symfony\Component\DependencyInjection\ContainerAwareInterface;
  10. use Symfony\Component\DependencyInjection\ContainerAwareTrait;
  11. /**
  12.  * Auto-generated Migration: Please modify to your needs!
  13.  */
  14. final class Version20240731130955DataUpdate extends AbstractMigration implements ContainerAwareInterface
  15. {
  16.     use ContainerAwareTrait;
  17.     public function getDescription(): string
  18.     {
  19.         return '';
  20.     }
  21.     public function up(Schema $schema): void
  22.     {
  23.         $entityManager $this->container->get('doctrine.orm.entity_manager');
  24.         /** @var ProjectStatusRepository $projectRepository */
  25.         $projectRepository $entityManager->getRepository(Project::class);
  26.         /** @var Project $project */
  27.         foreach ($projectRepository->findAll() as $project) {
  28.             $workflowSchema json_decode($project->getWorkflowSchema());
  29.             foreach ($workflowSchema as $stage) {
  30.                 if ($stage->stageData->name === $project->getStatus()->getName()) {
  31.                     $project->setIsProjectStatusInternal($stage->internal);
  32.                 }
  33.             }
  34.             $entityManager->persist($project);
  35.         }
  36.         $entityManager->flush();
  37.     }
  38. }