<?php

function smarty_function_insert_users_filter($params, &$smarty)
{
    $usersFilter = \KupShop\KupShopBundle\Util\Compat\ServiceContainer::getService(\KupShop\AdminBundle\Admin\UsersFilter::class);
    $templateName = $params['template_name'] ?? $usersFilter->getTemplate();
    $params = $params + [
        'filter_size' => empty($params['filter_size']) ? 1 : $params['filter_size'],
        'filter_data' => $usersFilter->getFilterData(),
        'filter' => $usersFilter->getFilter($params['filter'] ?? null),
    ];

    $_smarty_tpl_vars = $smarty->tpl_vars;

    echo $smarty->_subTemplateRender($templateName, $smarty->cache_id, $smarty->compile_id, 0, null, $params, 0, false);

    $smarty->tpl_vars = $_smarty_tpl_vars;
}
