* [misc] fix bug.

This commit is contained in:
sunguangming
2025-09-16 06:53:07 +00:00
parent 01e9567a5c
commit a22be845cc
2 changed files with 9 additions and 7 deletions
+8 -6
View File
@@ -45,12 +45,13 @@ class settingModel extends model
*
* @param string $path system.common.global.sn | system.common.sn | system.common.global.sn@rnd
* @param mixed $value
* @param string $delimiter
* @access public
* @return bool
*/
public function setItem(string $path, mixed $value = ''): bool
public function setItem(string $path, mixed $value = '', string $delimiter = '.'): bool
{
$item = $this->parseItemPath($path);
$item = $this->parseItemPath($path, $delimiter);
if(empty($item)) return false;
$item->value = strval($value);
@@ -160,10 +161,11 @@ class settingModel extends model
* Parse item path
*
* @param string $path system.common.global.sn | system.common.sn | system.common.global.sn@rnd
* @param string $delimiter
* @access public
* @return object|bool
*/
public function parseItemPath(string $path): object|bool
public function parseItemPath(string $path, string $delimiter = '.'): object|bool
{
/* Determine vision of config item. */
$pathVision = explode('@', $path);
@@ -179,12 +181,12 @@ class settingModel extends model
$path = preg_replace("/^{$account}/", 'account', $path);
}
$level = substr_count($path, '.');
$level = substr_count($path, $delimiter);
$section = '';
if($level <= 1) return false;
if($level == 2) list($owner, $module, $key) = explode('.', $path);
if($level == 3) list($owner, $module, $section, $key) = explode('.', $path);
if($level == 2) list($owner, $module, $key) = explode($delimiter, $path);
if($level == 3) list($owner, $module, $section, $key) = explode($delimiter, $path);
if($replace) $owner = $account;
$item = new stdclass();