migrations/Version20240405134950DataUpdate.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use App\Entity\Workflow\Action;
  5. use App\Repository\Workflow\ActionRepository;
  6. use Doctrine\DBAL\Schema\Schema;
  7. use Doctrine\Migrations\AbstractMigration;
  8. use Doctrine\ORM\EntityManagerInterface;
  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 Version20240405134950DataUpdate extends AbstractMigration implements ContainerAwareInterface
  15. {
  16.     use ContainerAwareTrait;
  17.     private $actions = [
  18.             Action::ACTION_EMAIL_TO_CLIENT => ['properties' => ['type' => 'emailToClient''parameters' => ['title''subject''content'], 'schedule' => ['day''hour''minute''fromProjectDate']]],
  19.             Action::ACTION_EMAIL_TO_EXTERNAL_PARTY => ['properties' => ['type' => 'emailToExternal''parameters' => ['title''subject''content''email'], 'schedule' => ['day''hour''minute''fromProjectDate']]],
  20.             Action::ACTION_EMAIL_TO_PROJECT_MANAGER => ['properties' => ['type' => 'emailToProjectManager''parameters' => ['title''subject''content''projectManagerSlug''sendToAllPMs''sendToDefaultPM'], 'schedule' => ['day''hour''minute''fromProjectDate']]],
  21.             Action::ACTION_EMAIL_TO_ADMIN => ['properties' => ['type' => 'emailToAdmin''parameters' => ['title''subject''content''adminSlug''sendToAllAdmins'], 'schedule' => ['day''hour''minute''fromProjectDate']]],
  22.             Action::ACTION_CHANGE_PROJECT_STATUS => ['properties' => ['type' => 'changeProjectStatus''parameters' => ['projectStatusSlug'], 'schedule' => ['day''hour''minute''fromProjectDate']]],
  23.     ];
  24.     public function getDescription(): string
  25.     {
  26.         return '';
  27.     }
  28.     public function up(Schema $schema): void
  29.     {
  30.                 // this up() migration is auto-generated, please modify it to your needs
  31.                 /** @var EntityManagerInterface $entityManager */
  32.                 $entityManager $this->container->get('doctrine.orm.entity_manager');
  33.                 $actionRepository $entityManager->getRepository(Action::class);
  34.         
  35.                 foreach ($this->actions as $key => $properties) {
  36.                     /** @var Action $dbAction */
  37.                     $dbAction $actionRepository->findOneBy(['name' => $key]);
  38.                     $dbAction->setProperties(json_encode($properties['properties']));
  39.                     $entityManager->persist($dbAction);
  40.                 }
  41.                 $entityManager->flush();
  42.     }
  43.     public function down(Schema $schema): void
  44.     {
  45.     }
  46. }