vendor/bluue/dhl-bundle/migrations/Version20230214143116.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DhlBundleMigrations;
  4. use App\Services\ObjectSerialize;
  5. use Doctrine\DBAL\Schema\Schema;
  6. use Doctrine\Migrations\AbstractMigration;
  7. use Symfony\Component\Uid\UuidV6;
  8. final class Version20230214143116 extends AbstractMigration
  9. {
  10.     private ObjectSerialize $objectSerialize;
  11.     public function setObjectSerialize(ObjectSerialize $objectSerialize)
  12.     {
  13.         $this->objectSerialize $objectSerialize;
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.     }
  18.     public function down(Schema $schema): void
  19.     {
  20.     }
  21.     public function postUp(Schema $schema): void
  22.     {
  23.         parent::postUp($schema);
  24.         $now = (new \DateTime())->format('Y-m-d H:i:s');
  25.         $templateMail dirname(__FILE__) . '/../src/Resources/views/TemplateMail/Fixtures/custom.html.twig';
  26.         $configurations = [
  27.             'dhl_bundle__send_email_when_label_generated' => false,
  28.             'dhl_bundle__template_mail' => file_get_contents($templateMail)
  29.         ];
  30.         foreach ($configurations as $configuration => $value) {
  31.             $this->connection->insert('configuration', [
  32.                 'id' => (new UuidV6())->toBinary(),
  33.                 'name' => $configuration,
  34.                 'context_id' => null,
  35.                 'value' => $this->objectSerialize->add((object) ['value' => $value]),
  36.                 'created_at' => $now,
  37.                 'updated_at' => $now
  38.             ]);
  39.         }
  40.     }
  41. }