<?php
/**
* 2023 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
*  @author    Anvanto <anvantoco@gmail.com>
*  @copyright 2023 Anvanto
*  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*/

if (!defined('_PS_VERSION_')) {
    exit;
}

function upgrade_module_2_4_8($object)
{
    $object->anThemeFiles->createFoldersJsCss();

    $listCss = glob($object->anThemeFiles->oldPathCss.'*.css');
    foreach ($listCss as $file){
        $nameFile = basename($file);
        if ($nameFile != 'back.css' && Tools::file_exists_no_cache($file)){
            if (Tools::copy($file, $object->anThemeFiles->pathCss . $nameFile)){
                @unlink($file);
            }
        }  
    }

    $listJs = glob($object->anThemeFiles->oldPathJs.'*.js');
    foreach ($listJs as $file){
        $nameFile = basename($file);
        if ($nameFile != 'back.js' && Tools::file_exists_no_cache($file)){
            if (Tools::copy($file, $object->anThemeFiles->pathJs . $nameFile)){
                @unlink($file);
            }
        }  
    }

    return true;
}