Cleanup config
* Add appname constant to application * Remove unused functions Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Родитель
2c68a4d196
Коммит
c81dc83493
|
@ -11,14 +11,15 @@
|
|||
|
||||
namespace OCA\Richdocuments;
|
||||
|
||||
use OCA\Richdocuments\AppInfo\Application;
|
||||
use \OCP\IConfig;
|
||||
|
||||
class AppConfig{
|
||||
private $appName = 'richdocuments';
|
||||
private $defaults = [
|
||||
'wopi_url' => 'https://localhost:9980'
|
||||
];
|
||||
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
public function __construct(IConfig $config) {
|
||||
|
@ -35,41 +36,16 @@ class AppConfig{
|
|||
if (array_key_exists($key, $this->defaults)){
|
||||
$defaultValue = $this->defaults[$key];
|
||||
}
|
||||
return $this->config->getAppValue($this->appName, $key, $defaultValue);
|
||||
return $this->config->getAppValue(Application::APPNAME, $key, $defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a value by key
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
* @return string
|
||||
* @return void
|
||||
*/
|
||||
public function setAppValue($key, $value) {
|
||||
return $this->config->setAppValue($this->appName, $key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a value by key for a user
|
||||
* @param string $userId
|
||||
* @param string $key
|
||||
* @return string
|
||||
*/
|
||||
public function getUserValue($userId, $key) {
|
||||
$defaultValue = null;
|
||||
if (array_key_exists($key, $this->defaults)){
|
||||
$defaultValue = $this->defaults[$key];
|
||||
}
|
||||
return $this->config->getUserValue($userId, $this->appName, $key, $defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a value by key for a user
|
||||
* @param string $userId
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
public function setUserValue($userId, $key, $value) {
|
||||
return $this->config->setAppValue($userId, $this->appName, $key, $value);
|
||||
$this->config->setAppValue(Application::APPNAME, $key, $value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,10 @@ use OCP\AppFramework\App;
|
|||
use OCP\AppFramework\IAppContainer;
|
||||
|
||||
class Application extends App {
|
||||
|
||||
const APPNAME = 'richdocuments';
|
||||
|
||||
public function __construct (array $urlParams = array()) {
|
||||
parent::__construct('richdocuments', $urlParams);
|
||||
parent::__construct(self::APPNAME, $urlParams);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче