* Add appname constant to application
* Remove unused functions

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-07-10 12:28:29 +02:00
Родитель 2c68a4d196
Коммит c81dc83493
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: F941078878347C0C
2 изменённых файлов: 9 добавлений и 30 удалений

Просмотреть файл

@ -11,14 +11,15 @@
namespace OCA\Richdocuments; namespace OCA\Richdocuments;
use OCA\Richdocuments\AppInfo\Application;
use \OCP\IConfig; use \OCP\IConfig;
class AppConfig{ class AppConfig{
private $appName = 'richdocuments';
private $defaults = [ private $defaults = [
'wopi_url' => 'https://localhost:9980' 'wopi_url' => 'https://localhost:9980'
]; ];
/** @var IConfig */
private $config; private $config;
public function __construct(IConfig $config) { public function __construct(IConfig $config) {
@ -35,41 +36,16 @@ class AppConfig{
if (array_key_exists($key, $this->defaults)){ if (array_key_exists($key, $this->defaults)){
$defaultValue = $this->defaults[$key]; $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 * Set a value by key
* @param string $key * @param string $key
* @param string $value * @param string $value
* @return string * @return void
*/ */
public function setAppValue($key, $value) { public function setAppValue($key, $value) {
return $this->config->setAppValue($this->appName, $key, $value); $this->config->setAppValue(Application::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);
} }
} }

Просмотреть файл

@ -27,7 +27,10 @@ use OCP\AppFramework\App;
use OCP\AppFramework\IAppContainer; use OCP\AppFramework\IAppContainer;
class Application extends App { class Application extends App {
const APPNAME = 'richdocuments';
public function __construct (array $urlParams = array()) { public function __construct (array $urlParams = array()) {
parent::__construct('richdocuments', $urlParams); parent::__construct(self::APPNAME, $urlParams);
} }
} }