<?php

declare(strict_types=1);

namespace KupShop\StoresBundle\Resources\script;

use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
use KupShop\StoresBundle\Utils\MainStoreMigrationUtil;

class MigrateToMainStoreScript extends \KupShop\AdminBundle\Util\Script\Script
{
    protected static $name = 'Migrovat položky na hlavní sklad';

    protected static $defaultParameters = [
        'run' => true,
    ];

    protected function run(array $arguments)
    {
        if (!$arguments['run'] && !isLocalDevelopment()) {
            return;
        }

        ini_set('memory_limit', '8G');

        /** @var MainStoreMigrationUtil $migrateUtil */
        $migrateUtil = ServiceContainer::getService(MainStoreMigrationUtil::class);
        $migrateUtil->migrate();

        $this->log('Sklad premigrovan.');

        $this->log('Importuji orders_stores');
        $migrateUtil->insertOrderStores();
        $this->log('orders_stores importovany.');
    }
}

return MigrateToMainStoreScript::class;
