public static function set($userId, $name, $value) { $setting = self::findOne(['user_id' => $userId, 'name' => $name]); if ($setting === null) { $setting = new UserSetting(); $setting->user_id = $userId; $setting->name = $name; } $setting->value = $value; $setting->save(); }
public function save() { if ($this->validate()) { UserSetting::set($this->userId, $this->gridId . '.pageSize', $this->pageSize); return true; } else { return false; } }
/** * @param $group * @param $name * @return UserSetting */ public function getSetting($group, $name) { return UserSetting::get($this->id, $group, $name); }
protected function setupGrid() { $this->trigger(self::EVENT_SETUP_GRID); if ($this->runInConsoleMode == false) { $pageSize = UserSetting::get(Yii::$app->user->id, $this->getGridId() . '.pageSize'); if ($pageSize !== null) { $this->dataProvider->getPagination()->pageSize = $pageSize; } } }
public function actionGet($name) { \Yii::$app->response->format = Response::FORMAT_JSON; return UserSetting::get(\Yii::$app->user->id, $name); }