vendor/bluue/prestashop-connector-bundle/migrations/Version20221208093052.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace PrestashopConnectorBundleMigrations;
  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 Version20221208093052 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.         $contexts $this->connection->executeQuery('SELECT * FROM context WHERE deleted_at IS NULL')
  26.             ->fetchAllAssociative();
  27.         $configurations = [
  28.             'prestashop_connector_bundle__shop_url' => 'https://www.ma-boutique.com/',
  29.             'prestashop_connector_bundle__invoices_generated_in_bluue' => false,
  30.             'prestashop_connector_bundle__sync_bluue_to_presta' => true
  31.         ];
  32.         foreach ($contexts as $context) {
  33.             foreach ($configurations as $configuration => $value) {
  34.                 $this->connection->insert('configuration', [
  35.                     'id' => (new UuidV6())->toBinary(),
  36.                     'name' => $configuration,
  37.                     'context_id' => $context['id'],
  38.                     'value' => $this->objectSerialize->add((object) ['value' => $value]),
  39.                     'created_at' => $now,
  40.                     'updated_at' => $now
  41.                 ]);
  42.             }
  43.         }
  44.         $this->connection->insert('cron_job', [
  45.             'name' => 'prestashop-sync-customer',
  46.             'command' => 'bluue-bundle:prestashop-connector:sync-customer',
  47.             'schedule' => '*/15 * * * *',
  48.             'description' => '',
  49.             'enabled' => 0
  50.         ]);
  51.         $this->connection->insert('cron_job', [
  52.             'name' => 'prestashop-sync-catalog',
  53.             'command' => 'bluue-bundle:prestashop-connector:sync-catalog',
  54.             'schedule' => '*/15 * * * *',
  55.             'description' => '',
  56.             'enabled' => 0
  57.         ]);
  58.         $this->connection->insert('cron_job', [
  59.             'name' => 'prestashop-sync-order',
  60.             'command' => 'bluue-bundle:prestashop-connector:sync-order',
  61.             'schedule' => '*/15 * * * *',
  62.             'description' => '',
  63.             'enabled' => 0
  64.         ]);
  65.     }
  66. }