40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?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;
|
|
}
|
|
}
|