<?php

use Gls\GlsPoland\PrestaShop\Configuration\Adapter\Configuration;
use Gls\GlsPoland\PrestaShop\Hook;
use Gls\GlsPoland\PrestaShop\Installer\DatabaseInstaller;
use Gls\GlsPoland\PrestaShop\Installer\Migration\Version1_1_7;

if (!defined('_PS_VERSION_')) {
    exit;
}

function upgrade_module_1_1_7(Module $module): bool
{
    /** @var \Doctrine\DBAL\Connection $connection */
    $connection = $module->get('database_connection');

    $installer = new DatabaseInstaller($connection, [
        Version1_1_7::create(),
    ], new Configuration(true));

    $installer->install($module);

    return $module->registerHook([
        Hook\Front\ActionValidateOrder::HOOK_NAME,
        Hook\Front\ActionObjectOrderAddAfter::HOOK_NAME,
        Hook\Front\Checkout\DisplayOrderConfirmation::HOOK_NAME,
    ]);
}
