first commit
This commit is contained in:
33
class/smarty_plugins/function.get_section.php
Normal file
33
class/smarty_plugins/function.get_section.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user