Browse Source

Add methods to get casted system values

Signed-off-by: Joas Schilling <coding@schilljs.com>
tags/v16.0.0alpha1
Joas Schilling 5 years ago
parent
commit
a11ef5134c
No account linked to committer's email address
2 changed files with 66 additions and 0 deletions
  1. 36
    0
      lib/private/AllConfig.php
  2. 30
    0
      lib/public/IConfig.php

+ 36
- 0
lib/private/AllConfig.php View File

@@ -125,6 +125,42 @@ class AllConfig implements \OCP\IConfig {
return $this->systemConfig->getValue($key, $default);
}

/**
* Looks up a boolean system wide defined value
*
* @param string $key the key of the value, under which it was saved
* @param mixed $default the default value to be returned if the value isn't set
* @return mixed the value or $default
* @since 16.0.0
*/
public function getSystemValueBool(string $key, bool $default = false): bool {
return (bool) $this->getSystemValue($key, $default);
}

/**
* Looks up an integer system wide defined value
*
* @param string $key the key of the value, under which it was saved
* @param mixed $default the default value to be returned if the value isn't set
* @return mixed the value or $default
* @since 16.0.0
*/
public function getSystemValueInt(string $key, int $default = 0): int {
return (int) $this->getSystemValue($key, $default);
}

/**
* Looks up a string system wide defined value
*
* @param string $key the key of the value, under which it was saved
* @param mixed $default the default value to be returned if the value isn't set
* @return mixed the value or $default
* @since 16.0.0
*/
public function getSystemValueString(string $key, string $default = ''): string {
return (string) $this->getSystemValue($key, $default);
}

/**
* Looks up a system wide defined value and filters out sensitive data
*

+ 30
- 0
lib/public/IConfig.php View File

@@ -74,6 +74,36 @@ interface IConfig {
*/
public function getSystemValue($key, $default = '');

/**
* Looks up a boolean system wide defined value
*
* @param string $key the key of the value, under which it was saved
* @param bool $default the default value to be returned if the value isn't set
* @return bool the value or $default
* @since 16.0.0
*/
public function getSystemValueBool(string $key, bool $default = false): bool;

/**
* Looks up an integer system wide defined value
*
* @param string $key the key of the value, under which it was saved
* @param int $default the default value to be returned if the value isn't set
* @return int the value or $default
* @since 16.0.0
*/
public function getSystemValueInt(string $key, int $default = 0): int;

/**
* Looks up a string system wide defined value
*
* @param string $key the key of the value, under which it was saved
* @param string $default the default value to be returned if the value isn't set
* @return string the value or $default
* @since 16.0.0
*/
public function getSystemValueString(string $key, string $default = ''): string;

/**
* Looks up a system wide defined value and filters out sensitive data
*

Loading…
Cancel
Save