src/Biz/System/Service/Impl/SettingServiceImpl.php

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php

namespace Biz\System\Service\Impl;

use Biz\BaseService;
use Biz\System\Service\SettingService;

class SettingServiceImpl extends BaseService implements SettingService
{
    const CACHE_NAME = 'settings';
    const NAME_SPACE_DEFAULT = 'default';

    private $cached;

    public function set($name, $value)
    {
        $this->getSettingDao()->deleteByName($name);
        $setting = array(
            'name' => $name,
            'value' => serialize($value),
        );
        $this->getSettingDao()->create($setting);
        $this->clearCache();
    }

    /**
     * @param $name
     * @param null $default
     *
     * @return array|mixed|null
     *                          get single node setting; eg: 'site.name.test' => get('site')['name']['test']
     */
    public function node($name, $default = null)
    {
        $names = explode('.', $name);

        $name = array_shift($names);

        if (empty($name)) {
            return $default;
        }

        $value = $this->get($name);

        if (!isset($value)) {
            return $default;
        }

        if (empty($names)) {
            return $value;
        }

        $result = $value;

        foreach ($names as $name) {
            if (!isset($result[$name])) {
                return $default;
            }

            $result = $result[$name];

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。