<?php

namespace KupShop\OrderingBundle\Resources\upgrade;

class SplitSetItemUpgrade extends \UpgradeNew
{
    public function check_SplitSetItemSetup()
    {
        $dbcfg = \Settings::getDefault();

        return findModule(\Modules::PRODUCT_SETS) && empty($dbcfg['products_sets']['split']);
    }

    public function upgrade_SplitSetItemSetup()
    {
        $dbcfg = \Settings::getDefault();
        if (findModule(\Modules::PRODUCT_SETS, \Modules::SUB_SPLIT_PRICE_VAT)) {
            $dbcfg->products_sets = ['split' => 'price_vat'];
        } else {
            $dbcfg->products_sets = ['split' => 'price_default'];
        }
        $dbcfg->saveToDB();
        $this->upgradeOK();
    }
}
