migrations/Version20240506112902DataUpdate.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use App\Entity\Workflow\MailTag;
  5. use Doctrine\DBAL\Schema\Schema;
  6. use Doctrine\Migrations\AbstractMigration;
  7. use Symfony\Component\DependencyInjection\ContainerAwareInterface;
  8. use Symfony\Component\DependencyInjection\ContainerAwareTrait;
  9. /**
  10.  * Auto-generated Migration: Please modify to your needs!
  11.  */
  12. final class Version20240506112902DataUpdate extends AbstractMigration implements ContainerAwareInterface
  13. {
  14.     use ContainerAwareTrait;
  15.     private $mailTags = [
  16.         [
  17.             'name' => MailTag::MAIL_TAG_RECEIVER,
  18.             'visibleName' => '[@receiver]',
  19.             'description' => 'Show the reciever\'s name and surname.',
  20.         ],
  21.         [
  22.             'name' => MailTag::MAIL_TAG_COMPANY_NAME,
  23.             'visibleName' => '[@companyName]',
  24.             'description' => 'Show client\'s company name.',
  25.         ],
  26.         [
  27.             'name' => MailTag::MAIL_TAG_PROJECT_NAME,
  28.             'visibleName' => '[@projectName]',
  29.             'description' => 'Show project\'s name.',
  30.         ],
  31.         [
  32.             'name' => MailTag::MAIL_TAG_PROJECT_MANAGER_NAME,
  33.             'visibleName' => '[@projectManagerName]',
  34.             'description' => 'Show project manager name and surname.',
  35.         ],
  36.         [
  37.             'name' => MailTag::MAIL_TAG_PROJECT_STATUS_NAME,
  38.             'visibleName' => '[@projectStatusName]',
  39.             'description' => 'Show project\'s status name.',
  40.         ],
  41.         [
  42.             'name' => MailTag::MAIL_TAG_DATE_TODAY,
  43.             'visibleName' => '[@dateToday]',
  44.             'description' => 'Show date on the day the email was sent.',
  45.         ],
  46.  
  47.     ];
  48.     public function getDescription(): string
  49.     {
  50.         return '';
  51.     }
  52.     public function up(Schema $schema): void
  53.     {
  54.         $entityManager $this->container->get('doctrine.orm.entity_manager');
  55.         foreach ($this->mailTags as $mailTag) {
  56.             $newMailTag = new MailTag();
  57.             $newMailTag->setName($mailTag['name']);
  58.             $newMailTag->setVisibleName($mailTag['visibleName']);
  59.             $newMailTag->setDescription($mailTag['description']);
  60.             $entityManager->persist($newMailTag);
  61.         }
  62.         $entityManager->flush();
  63.     }
  64.     public function down(Schema $schema): void
  65.     {
  66.     }
  67. }