#12687 Initialize result
This commit is contained in:
parent
15382049b8
commit
a43b2b1c59
|
@ -1258,7 +1258,7 @@ class Prd
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'groups[0]' => [
|
'groups[0]' => [
|
||||||
'conditional_refs' => [
|
'conditional_refs' => [
|
||||||
[
|
[
|
||||||
'when' => [
|
'when' => [
|
||||||
|
@ -1633,13 +1633,6 @@ class Prd
|
||||||
'tservice_element' => ['rules'],
|
'tservice_element' => ['rules'],
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->result = [
|
|
||||||
'status' => true,
|
|
||||||
'items' => [],
|
|
||||||
'errors' => [],
|
|
||||||
'info' => []
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->currentItem = [
|
$this->currentItem = [
|
||||||
'table' => '',
|
'table' => '',
|
||||||
'value' => '',
|
'value' => '',
|
||||||
|
@ -1652,6 +1645,22 @@ class Prd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize result
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function initializeResult()
|
||||||
|
{
|
||||||
|
$this->result = [
|
||||||
|
'status' => true,
|
||||||
|
'items' => [],
|
||||||
|
'errors' => [],
|
||||||
|
'info' => [],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills result with status.
|
* Fills result with status.
|
||||||
*
|
*
|
||||||
|
@ -1681,6 +1690,7 @@ class Prd
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills result with info message.
|
* Fills result with info message.
|
||||||
*
|
*
|
||||||
|
@ -1693,6 +1703,7 @@ class Prd
|
||||||
$this->result['info'][] = $msg;
|
$this->result['info'][] = $msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills result with error message.
|
* Fills result with error message.
|
||||||
*
|
*
|
||||||
|
@ -1949,18 +1960,19 @@ class Prd
|
||||||
$keys = [];
|
$keys = [];
|
||||||
foreach ($matches as $match) {
|
foreach ($matches as $match) {
|
||||||
if (isset($match[2]) === true) {
|
if (isset($match[2]) === true) {
|
||||||
$keys[] = (int)$match[2];
|
$keys[] = (int) $match[2];
|
||||||
} else {
|
} else {
|
||||||
$keys[] = $match[1];
|
$keys[] = $match[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$lastIndex = count($keys) - 1;
|
$lastIndex = (count($keys) - 1);
|
||||||
$updated_data = &$data;
|
$updated_data = &$data;
|
||||||
|
|
||||||
for ($i = 0; $i < $lastIndex; $i++) {
|
for ($i = 0; $i < $lastIndex; $i++) {
|
||||||
$updated_data = &$updated_data[$keys[$i]];
|
$updated_data = &$updated_data[$keys[$i]];
|
||||||
}
|
}
|
||||||
|
|
||||||
$updated_data[$keys[$lastIndex]] = $newValue;
|
$updated_data[$keys[$lastIndex]] = $newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1998,7 +2010,7 @@ class Prd
|
||||||
*/
|
*/
|
||||||
private function evalConditionalRef($compare_value, $when)
|
private function evalConditionalRef($compare_value, $when)
|
||||||
{
|
{
|
||||||
if(is_array($when) === true) {
|
if (is_array($when) === true) {
|
||||||
$when_value = reset($when);
|
$when_value = reset($when);
|
||||||
} else {
|
} else {
|
||||||
$when_value = $when;
|
$when_value = $when;
|
||||||
|
@ -2083,7 +2095,6 @@ class Prd
|
||||||
if ($this->evalConditionalRef($compare_value, $condition['when']) === true
|
if ($this->evalConditionalRef($compare_value, $condition['when']) === true
|
||||||
&& empty($value) === false
|
&& empty($value) === false
|
||||||
) {
|
) {
|
||||||
|
|
||||||
$ref = $condition['ref'];
|
$ref = $condition['ref'];
|
||||||
if (isset($ref['join']) === true) {
|
if (isset($ref['join']) === true) {
|
||||||
$join_array = $this->recursiveJoin(
|
$join_array = $this->recursiveJoin(
|
||||||
|
@ -2146,8 +2157,8 @@ class Prd
|
||||||
$value
|
$value
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2656,6 +2667,8 @@ class Prd
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
$this->initializeResult();
|
||||||
|
|
||||||
if (empty($data_file['prd_data']) === false) {
|
if (empty($data_file['prd_data']) === false) {
|
||||||
$type = $data_file['prd_data']['type'];
|
$type = $data_file['prd_data']['type'];
|
||||||
$name = io_safe_input($data_file['prd_data']['name']);
|
$name = io_safe_input($data_file['prd_data']['name']);
|
||||||
|
@ -2902,16 +2915,18 @@ class Prd
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Eval autocreate Item.
|
* Eval autocreate Item.
|
||||||
*
|
*
|
||||||
* @param array $ref References.
|
* @param array $ref References.
|
||||||
* @param string $value Current value.
|
* @param string $value Current value.
|
||||||
* @param string $column Table column.
|
* @param string $column Table column.
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
private function evalAutocreateItem(array $ref, string $value='', string $column='') {
|
private function evalAutocreateItem(array $ref, string $value='', string $column='')
|
||||||
|
{
|
||||||
if (isset($ref['autocreate_item']) === true) {
|
if (isset($ref['autocreate_item']) === true) {
|
||||||
$this->autocreateItem(
|
$this->autocreateItem(
|
||||||
$ref,
|
$ref,
|
||||||
|
@ -2926,6 +2941,7 @@ class Prd
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Autocreate Item.
|
* Autocreate Item.
|
||||||
*
|
*
|
||||||
|
@ -3157,9 +3173,7 @@ class Prd
|
||||||
[
|
[
|
||||||
'table' => 'tgrupo',
|
'table' => 'tgrupo',
|
||||||
'id' => ['id_grupo'],
|
'id' => ['id_grupo'],
|
||||||
'fields' => [
|
'fields' => ['nombre' => $found_value],
|
||||||
'nombre' => $found_value,
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
@ -3171,9 +3185,7 @@ class Prd
|
||||||
[
|
[
|
||||||
'table' => 'tmodule_group',
|
'table' => 'tmodule_group',
|
||||||
'id' => ['id_mg'],
|
'id' => ['id_mg'],
|
||||||
'fields' => [
|
'fields' => ['name' => $found_value],
|
||||||
'name' => $found_value,
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
@ -3185,9 +3197,7 @@ class Prd
|
||||||
[
|
[
|
||||||
'table' => 'tconfig_os',
|
'table' => 'tconfig_os',
|
||||||
'id' => ['id_os'],
|
'id' => ['id_os'],
|
||||||
'fields' => [
|
'fields' => ['name' => $found_value],
|
||||||
'name' => $found_value,
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
@ -3199,9 +3209,7 @@ class Prd
|
||||||
[
|
[
|
||||||
'table' => 'tcategory',
|
'table' => 'tcategory',
|
||||||
'id' => ['id'],
|
'id' => ['id'],
|
||||||
'fields' => [
|
'fields' => ['name' => $found_value],
|
||||||
'name' => $found_value,
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
@ -3213,9 +3221,7 @@ class Prd
|
||||||
[
|
[
|
||||||
'table' => 'ttag',
|
'table' => 'ttag',
|
||||||
'id' => ['id_tag'],
|
'id' => ['id_tag'],
|
||||||
'fields' => [
|
'fields' => ['name' => $found_value],
|
||||||
'name' => $found_value,
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue