<?php
declare(strict_types=1);
namespace PrestashopConnectorBundleMigrations;
use App\Services\ObjectSerialize;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Symfony\Component\Uid\UuidV6;
final class Version20221208093052 extends AbstractMigration
{
private ObjectSerialize $objectSerialize;
public function setObjectSerialize(ObjectSerialize $objectSerialize)
{
$this->objectSerialize = $objectSerialize;
}
public function up(Schema $schema): void
{
}
public function down(Schema $schema): void
{
}
public function postUp(Schema $schema): void
{
parent::postUp($schema);
$now = (new \DateTime())->format('Y-m-d H:i:s');
$contexts = $this->connection->executeQuery('SELECT * FROM context WHERE deleted_at IS NULL')
->fetchAllAssociative();
$configurations = [
'prestashop_connector_bundle__shop_url' => 'https://www.ma-boutique.com/',
'prestashop_connector_bundle__invoices_generated_in_bluue' => false,
'prestashop_connector_bundle__sync_bluue_to_presta' => true
];
foreach ($contexts as $context) {
foreach ($configurations as $configuration => $value) {
$this->connection->insert('configuration', [
'id' => (new UuidV6())->toBinary(),
'name' => $configuration,
'context_id' => $context['id'],
'value' => $this->objectSerialize->add((object) ['value' => $value]),
'created_at' => $now,
'updated_at' => $now
]);
}
}
$this->connection->insert('cron_job', [
'name' => 'prestashop-sync-customer',
'command' => 'bluue-bundle:prestashop-connector:sync-customer',
'schedule' => '*/15 * * * *',
'description' => '',
'enabled' => 0
]);
$this->connection->insert('cron_job', [
'name' => 'prestashop-sync-catalog',
'command' => 'bluue-bundle:prestashop-connector:sync-catalog',
'schedule' => '*/15 * * * *',
'description' => '',
'enabled' => 0
]);
$this->connection->insert('cron_job', [
'name' => 'prestashop-sync-order',
'command' => 'bluue-bundle:prestashop-connector:sync-order',
'schedule' => '*/15 * * * *',
'description' => '',
'enabled' => 0
]);
}
}