From d3dbbfe3e7f7ff604c82f126d0940016c76ec4f8 Mon Sep 17 00:00:00 2001 From: liugang Date: Fri, 7 Apr 2023 02:31:28 +0000 Subject: [PATCH] * Refactor: only process a chart object. --- module/chart/model.php | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/module/chart/model.php b/module/chart/model.php index 633a55ad3f..4be9cfcc82 100644 --- a/module/chart/model.php +++ b/module/chart/model.php @@ -63,28 +63,22 @@ class chartModel extends model /** * Process sql and correct type. * - * @param object|array $charts - * @param bool $isObject + * @param object $chart * @access public - * @return object|array + * @return object */ - public function processChart($charts, $isObject = true) + public function processChart($chart) { - if($isObject) $charts = array($charts); + if(!empty($chart->sql)) $chart->sql = trim(str_replace(';', '', $chart->sql)); + if(!empty($chart->settings)) $chart->settings = json_decode($chart->settings, true); - foreach($charts as $id => $chart) + if(!empty($chart->settings) and is_array($chart->settings)) { - if(!empty($chart->sql)) $charts[$id]->sql = trim(str_replace(';', '', $chart->sql)); - if(!empty($chart->settings)) $charts[$id]->settings = json_decode($chart->settings, true); - - if(!empty($chart->settings) and is_array($chart->settings)) - { - $firstSetting = current($chart->settings); - if(isset($firstSetting['type'])) $charts[$id]->type = $firstSetting['type']; - } + $firstSetting = current($chart->settings); + if(isset($firstSetting['type'])) $chart->type = $firstSetting['type']; } - return $isObject ? reset($charts) : $charts; + return $chart; } /**