first commit
This commit is contained in:
39
class/smarty_plugins/function.get_parameter_info.php
Normal file
39
class/smarty_plugins/function.get_parameter_info.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use KupShop\I18nBundle\Translations\ParametersListTranslation;
|
||||
use KupShop\I18nBundle\Translations\ParametersTranslation;
|
||||
|
||||
function smarty_function_get_parameter_info($params, &$smarty)
|
||||
{
|
||||
if (empty($params['id'])) {
|
||||
trigger_error("Chybějící parametr 'id'");
|
||||
}
|
||||
|
||||
$result = sqlQueryBuilder()
|
||||
->select('pa.*')
|
||||
->from('parameters', 'pa')
|
||||
->where(\Query\Operator::equals(['pa.id' => $params['id']]))
|
||||
->andWhere(\Query\Translation::coalesceTranslatedFields(ParametersTranslation::class))
|
||||
->execute()
|
||||
->fetch();
|
||||
|
||||
$result['values'] = sqlFetchAll(sqlQueryBuilder()
|
||||
->select('pl.*')
|
||||
->from('parameters_list', 'pl')
|
||||
->where(\Query\Operator::equals(['pl.id_parameter' => $params['id']]))
|
||||
->andWhere(\Query\Translation::coalesceTranslatedFields(ParametersListTranslation::class))
|
||||
->orderBy('position')
|
||||
->execute(), 'id');
|
||||
|
||||
$result['values'] = array_map(function ($parameter) {
|
||||
$parameter['data'] = json_decode($parameter['data'], true);
|
||||
|
||||
return $parameter;
|
||||
}, $result['values']);
|
||||
|
||||
if (!empty($params['assign'])) {
|
||||
$smarty->assign($params['assign'], $result);
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user