<?php
/** 
 * @package     VikRestaurants
 * @subpackage  core
 * @author      E4J s.r.l.
 * @copyright   Copyright (C) 2023 E4J s.r.l. All Rights Reserved.
 * @license     http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @link        https://vikwp.com
 */

namespace E4J\VikRestaurants\Update\Adapters\Update1_11;

// No direct access
defined('ABSPATH') or die('No script kiddies please!');

use E4J\VikRestaurants\Update\UpdateRule;

/**
 * Fixes the current environment.css vars to support the new parameters introduced with the latest version.
 *
 * @since 1.11
 */
class CustomizerEnvironmentFixer extends UpdateRule
{
    /**
     * @inheritDoc
     */
    protected function run($parent)
    {
        // create the customizer back-end model
        $customizerModel = \JModelVRE::getInstance('customizer');

        // Load the current environment variables.
        // The missing variables are automatically loaded from the default file.
        $env = $customizerModel->getItem('environment');

        // commit the changes to have a CSS up-to-date
        $customizerModel->save($env);

        return true;
    }
}
