<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use App\Entity\Workflow\Action;
use App\Entity\Workflow\Trigger;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240404132642DataUpdate extends AbstractMigration implements ContainerAwareInterface
{
use ContainerAwareTrait;
private $triggers = [
[
'name' => Trigger::TRIGGER_PROJECT_STATUS_REACHED,
'visibleName' => 'Project status reached',
'operation' => 'Run actions when project reched status',
'description' => 'Description about project status reached.',
],
[
'name' => Trigger::TRIGGER_PROJECT_STATUS_FINISHED,
'visibleName' => 'Project status finished',
'operation' => 'Run actions when project finished status',
'description' => 'Description about project status finished.',
],
[
'name' => Trigger::TRIGGER_BEFORE_DEADLINE,
'visibleName' => 'Before deadline',
'operation' => 'Run actions X time before deadline',
'description' => 'Description about before deadline.',
],
[
'name' => Trigger::TRIGGER_DEADLINE_REACHED,
'visibleName' => 'Deadline reached',
'operation' => 'Run actions when project reached deadline.',
'description' => 'Description about before deadline.',
],
[
'name' => Trigger::TRIGGER_AFTER_DEADLINE,
'visibleName' => 'After deadline',
'operation' => 'Run actions X time after deadline',
'description' => 'Description about after deadline.',
],
];
private $actions = [
[
'name' => Action::ACTION_EMAIL_TO_CLIENT,
'visibleName' => 'Email to client',
'operation' => 'Send an e-mail to the specified client X time after triggering',
'description' => 'Description about ACTION_EMAIL_TO_CLIENT.',
],
[
'name' => Action::ACTION_EMAIL_TO_EXTERNAL_PARTY,
'visibleName' => 'Email to external party',
'operation' => 'Send an e-mail to the external party X time after triggering',
'description' => 'Description about ACTION_EMAIL_TO_EXTERNAL_PARTY.',
],
[
'name' => Action::ACTION_EMAIL_TO_PROJECT_MANAGER,
'visibleName' => 'Email to project manager',
'operation' => 'Send an e-mail to the project manager X time after triggering',
'description' => 'Description about ACTION_EMAIL_TO_PROJECT_MANAGER.',
],
[
'name' => Action::ACTION_EMAIL_TO_ADMIN,
'visibleName' => 'Email to admin',
'operation' => 'Send an e-mail to the admins X time after triggering',
'description' => 'Description about ACTION_EMAIL_TO_ADMIN.',
],
[
'name' => Action::ACTION_CHANGE_PROJECT_STATUS,
'visibleName' => 'Change project status',
'operation' => 'Change project from X status to Y status',
'description' => 'Description about ACTION_CHANGE_PROJECT_STATUS.',
],
];
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$entityManager = $this->container->get('doctrine.orm.entity_manager');
foreach ($this->triggers as $trigger) {
$newTrigger = new Trigger();
$newTrigger->setName($trigger['name']);
$newTrigger->setVisibleName($trigger['visibleName']);
$newTrigger->setOperation($trigger['operation']);
$newTrigger->setDescription($trigger['description']);
$entityManager->persist($newTrigger);
}
foreach ($this->actions as $action) {
$newAction = new Action();
$newAction->setName($action['name']);
$newAction->setVisibleName($action['visibleName']);
$newAction->setOperation($action['operation']);
$newAction->setDescription($action['description']);
$entityManager->persist($newAction);
}
$entityManager->flush();
}
public function down(Schema $schema): void
{
}
}