<?php

/*
 * Smarty plugin
 * -------------------------------------------------------------
 * Type:     function
 * Name:     get_slider
 * Purpose:  get a slider of known name or id
 * -------------------------------------------------------------
 */
function smarty_function_get_active_category($params, &$smarty)
{
    $category = null;
    $breadcrumb = null;
    $exact = false;
    $returnNav = [];

    extract($params);

    if (empty($returnNav)) {
        return;
    }

    $activeCategory = \KupShop\KupShopBundle\Util\Compat\ServiceContainer::getService(\KupShop\CatalogBundle\Util\ActiveCategory::class);

    $result = [
        'category' => $activeCategory->getCategory(),
        'breadcrumb' => $activeCategory->findBreadcrumb($returnNav),
    ];

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