/** * Set user config * * @param $key * @param $value * @param null $access_token_id * @return bool|User_config * @throws Exception */ public function setConfig($key, $value, $access_token_id = null) { $config = Config::get_by_key($key); if (!$config->id) { throw new Exception('There is no config with this key'); } if (!($userConfig = $this->ifUserHasConfig($key, $access_token_id))) { $userConfig = new User_config(); } $userConfig->value = $value; $userConfig->access_token_id = $access_token_id; $userConfig->save(array('user' => $this, 'config' => $config)); return $userConfig; }