<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use App\Entity\Workflow\Action;
use App\Repository\Workflow\ActionRepository;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240405134950DataUpdate extends AbstractMigration implements ContainerAwareInterface
{
use ContainerAwareTrait;
private $actions = [
Action::ACTION_EMAIL_TO_CLIENT => ['properties' => ['type' => 'emailToClient', 'parameters' => ['title', 'subject', 'content'], 'schedule' => ['day', 'hour', 'minute', 'fromProjectDate']]],
Action::ACTION_EMAIL_TO_EXTERNAL_PARTY => ['properties' => ['type' => 'emailToExternal', 'parameters' => ['title', 'subject', 'content', 'email'], 'schedule' => ['day', 'hour', 'minute', 'fromProjectDate']]],
Action::ACTION_EMAIL_TO_PROJECT_MANAGER => ['properties' => ['type' => 'emailToProjectManager', 'parameters' => ['title', 'subject', 'content', 'projectManagerSlug', 'sendToAllPMs', 'sendToDefaultPM'], 'schedule' => ['day', 'hour', 'minute', 'fromProjectDate']]],
Action::ACTION_EMAIL_TO_ADMIN => ['properties' => ['type' => 'emailToAdmin', 'parameters' => ['title', 'subject', 'content', 'adminSlug', 'sendToAllAdmins'], 'schedule' => ['day', 'hour', 'minute', 'fromProjectDate']]],
Action::ACTION_CHANGE_PROJECT_STATUS => ['properties' => ['type' => 'changeProjectStatus', 'parameters' => ['projectStatusSlug'], 'schedule' => ['day', 'hour', 'minute', 'fromProjectDate']]],
];
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
/** @var EntityManagerInterface $entityManager */
$entityManager = $this->container->get('doctrine.orm.entity_manager');
$actionRepository = $entityManager->getRepository(Action::class);
foreach ($this->actions as $key => $properties) {
/** @var Action $dbAction */
$dbAction = $actionRepository->findOneBy(['name' => $key]);
$dbAction->setProperties(json_encode($properties['properties']));
$entityManager->persist($dbAction);
}
$entityManager->flush();
}
public function down(Schema $schema): void
{
}
}