<?php

use KupShop\KupShopBundle\Util\DateUtil;

/**
 * @params['opening_hours'] - opening hours from, to or you can add a break break_from, break_to
 *
 * @return array['is_open'=>bool,'is_open_today'=> bool|['from'=> ,'to'=> ,'break_from'=>, 'break_to'=>] ]
 */
function smarty_function_load_opening_hours($params, &$smarty)
{
    $result = [
        'is_open' => false,
        'is_open_today' => false,
    ];

    if (!empty($params['opening_hours'])) {
        $result = DateUtil::isOpen($params['opening_hours']);
    }

    if (!empty($params['assign'])) {
        $smarty->assign($params['assign'], $result);
    } else {
        return $result;
    }
}
