public static function getConfigValue($id) { $model = Config::findOne(['id' => $id]); if ($model === null) { return '不存在配置项:' . $id; } return $model->value; }
public static function getModel($id, $fromCache = true) { $cacheKey = self::CachePrefix . $id; $value = $fromCache ? LuLu::getCache($cacheKey) : false; if ($value === false) { $value = Config::findOne(['id' => $id]); if ($value !== null) { LuLu::setCache($cacheKey, $value); } } return $value; }
/** * 初始使值 * @param type $model * @param type $attributes * @return type */ public static function initValueInternal($model, $attributes) { if ($attributes) { foreach ($attributes as $key) { $cmodel = Config::findOne(['`key`' => $key]); if ($cmodel) { $model->{$key} = $cmodel->value; } } } return $model; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Config::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'key', $this->key])->andFilterWhere(['like', 'value', $this->value]); return $dataProvider; }
/** * 获取网站的名称 * @return type */ public static function getSiteName() { $site_name = Config::getConfig('site_name'); return $site_name ? $site_name : ''; }
/** * 获取配置值 * @param string $id * @param boolean $fromCache * @return string */ public static function getConfigValue($id, $fromCache = true) { return Config::getValue($id, $fromCache); }
protected function saveOneInternal($id, $value) { Config::updateAll(['value' => $value], ['id' => $id]); }
public static function getConfig($key) { $model = Config::findOne(['`key`' => $key]); return empty($model) ? '' : $model->value; }
/** * 获取系统配置的值 * @param string $key 系统配置的键 * @param boolean $fromCache 是否从缓存中读取 * @return string $name 系统配置的值 */ public static function getConfigValue($key, $fromCache = true) { return \source\models\Config::getConfig($key); }