Files
kupshop/class/smarty_plugins/function.get_section.php
2025-08-02 16:30:27 +02:00

34 lines
899 B
PHP

<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: get_section
* Purpose: get a section of given id
* -------------------------------------------------------------
*/
use KupShop\CatalogBundle\Entity\Wrapper\CategoryWrapper;
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
function smarty_function_get_section($params, &$smarty)
{
if (!isset($params['id'])) {
return null;
}
$sectionTree = ServiceContainer::getService(\KupShop\CatalogBundle\Section\SectionTree::class);
$section = $sectionTree->getSectionById($params['id']);
if ($section) {
$section = ServiceContainer::getService(CategoryWrapper::class)->setObject($section);
} else {
$section = [];
}
if (!empty($params['assign'])) {
$smarty->assign($params['assign'], $section);
}
}