AddonModel::startAddons PHP Method

startAddons() public method

通过插件名称启动插件
public startAddons ( string $name ) : boolean
$name string 插件名称
return boolean 插件是否启动
    public function startAddons($name)
    {
        // 先查看该插件是否安装
        $map['name'] = t($name);
        $addon = $this->where($map)->find();
        // 装载缓存列表
        $this->_getFileAddons();
        if (!isset($this->fileAddons[$name])) {
            return false;
            // throw new ThinkException("插件".$name."的目录不存在");
        }
        // 如果安装后启用的,设置插件启动
        if ($addon && $addon['status'] == 0) {
            $save['status'] = '1';
            $result = $this->where($map)->save($save) ? true : false;
        } elseif ($addon && $addon['status'] == 1) {
            $result = false;
        } else {
            $addonObject = $this->fileAddons[$name];
            $add = $addonObject->getAddonInfo();
            $add['name'] = $name;
            $add['status'] = '1';
            if ($this->add($add) && $addonObject->install()) {
                $result = true;
            } else {
                $result = false;
            }
        }
        if ($result) {
            $addonCacheList = $this->resetAddonCache();
            S('system_addons_list', $addonCacheList);
        }
        return $result;
    }