<?php

use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
use KupShop\SellerBundle\Utils\SellerUtil;

function smarty_function_get_seller_opening_hours($params, &$smarty)
{
    $sellerUtil = ServiceContainer::getService(SellerUtil::class);
    $result = [];

    if ($params['seller'] ?? false) {
        $result = $sellerUtil->getOpeningHours($params['seller'], new DateTime());
    }

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