Nextcloud PHP API (master)

IAppConfig

Wrapper for AppConfig for the AppFramework

Tags
since
20.0.0

Table of Contents

Methods

deleteAppValue()  : void
Delete an app wide defined value
deleteAppValues()  : void
Removes all keys in appconfig belonging to the app
deleteUserValue()  : void
Delete a user value
getAllAppValues()  : array<string, string|int|float|bool|array<string|int, mixed>>
List all config values from an app with config key starting with $key.
getAppKeys()  : array<string|int, string>
Get all keys stored for this app
getAppValue()  : string
Looks up an app wide defined value
getAppValueArray()  : array<string|int, mixed>
Get config value assigned to a config key.
getAppValueBool()  : bool
Get config value assigned to a config key.
getAppValueFloat()  : float
Get config value assigned to a config key.
getAppValueInt()  : int
Get config value assigned to a config key.
getAppValueString()  : string
Get config value assigned to a config key.
getUserValue()  : string
Shortcut for getting a user defined value
hasAppKey()  : bool
Check if a key exists in the list of stored config values.
isLazy()  : bool
Returns if the config key stored in database is lazy loaded
isSensitive()  : bool
best way to see if a value is set as sensitive (not displayed in report)
setAppValue()  : void
Writes a new app wide value
setAppValueArray()  : bool
Store a config key and its value in database
setAppValueBool()  : bool
Store a config key and its value in database
setAppValueFloat()  : bool
Store a config key and its value in database.
setAppValueInt()  : bool
Store a config key and its value in database
setAppValueString()  : bool
Store a config key and its value in database
setUserValue()  : void
Set a user defined value

Methods

deleteAppValue()

Delete an app wide defined value

public deleteAppValue(string $key) : void
Parameters
$key : string

the key of the value, under which it was saved

Tags
since
20.0.0

deleteAppValues()

Removes all keys in appconfig belonging to the app

public deleteAppValues() : void
Tags
since
20.0.0

deleteUserValue()

Delete a user value

public deleteUserValue(string $userId, string $key) : void
Parameters
$userId : string

the userId of the user that we want to store the value under

$key : string

the key under which the value is being stored

Tags
since
20.0.0

getAllAppValues()

List all config values from an app with config key starting with $key.

public getAllAppValues([string $key = '' ][, bool $filtered = false ]) : array<string, string|int|float|bool|array<string|int, mixed>>

Returns an array with config key as key, stored value as value.

WARNING: ignore lazy filtering, all config values are loaded from database

Parameters
$key : string = ''

config keys prefix to search, can be empty.

$filtered : bool = false

filter sensitive config values

Tags
since
29.0.0
Return values
array<string, string|int|float|bool|array<string|int, mixed>>

[configKey => configValue]

getAppKeys()

Get all keys stored for this app

public getAppKeys() : array<string|int, string>
Tags
since
20.0.0
Return values
array<string|int, string>

the keys stored for the app

getAppValue()

Looks up an app wide defined value

public getAppValue(string $key[, string $default = '' ]) : string
Parameters
$key : string

the key of the value, under which it was saved

$default : string = ''

the default value to be returned if the value isn't set

Tags
since
20.0.0
deprecated
29.0.0

use getAppValueString()

Return values
string

the saved value

getAppValueArray()

Get config value assigned to a config key.

public getAppValueArray(string $key[, array<string|int, mixed> $default = [] ][, bool $lazy = false ]) : array<string|int, mixed>

If config key is not found in database, default value is returned. If config key is set as lazy loaded, the $lazy argument needs to be set to TRUE.

Parameters
$key : string

config key

$default : array<string|int, mixed> = []

default value

$lazy : bool = false

search within lazy loaded config

Tags
since
29.0.0
see
IAppConfig

for explanation about lazy loading

Return values
array<string|int, mixed>

stored config value or $default if not set in database

getAppValueBool()

Get config value assigned to a config key.

public getAppValueBool(string $key[, bool $default = false ][, bool $lazy = false ]) : bool

If config key is not found in database, default value is returned. If config key is set as lazy loaded, the $lazy argument needs to be set to TRUE.

Parameters
$key : string

config key

$default : bool = false

default value

$lazy : bool = false

search within lazy loaded config

Tags
since
29.0.0
see
IAppConfig

for explanation about lazy loading

Return values
bool

stored config value or $default if not set in database

getAppValueFloat()

Get config value assigned to a config key.

public getAppValueFloat(string $key[, float $default = 0 ][, bool $lazy = false ]) : float

If config key is not found in database, default value is returned. If config key is set as lazy loaded, the $lazy argument needs to be set to TRUE.

Parameters
$key : string

config key

$default : float = 0

default value

$lazy : bool = false

search within lazy loaded config

Tags
since
29.0.0
see
IAppConfig

for explanation about lazy loading

Return values
float

stored config value or $default if not set in database

getAppValueInt()

Get config value assigned to a config key.

public getAppValueInt(string $key[, int $default = 0 ][, bool $lazy = false ]) : int

If config key is not found in database, default value is returned. If config key is set as lazy loaded, the $lazy argument needs to be set to TRUE.

Parameters
$key : string

config key

$default : int = 0

default value

$lazy : bool = false

search within lazy loaded config

Tags
since
29.0.0
see
IAppConfig

for explanation about lazy loading

Return values
int

stored config value or $default if not set in database

getAppValueString()

Get config value assigned to a config key.

public getAppValueString(string $key[, string $default = '' ][, bool $lazy = false ]) : string

If config key is not found in database, default value is returned. If config key is set as lazy loaded, the $lazy argument needs to be set to TRUE.

Parameters
$key : string

config key

$default : string = ''

default value

$lazy : bool = false

search within lazy loaded config

Tags
since
29.0.0
see
IAppConfig

for explanation about lazy loading

Return values
string

stored config value or $default if not set in database

getUserValue()

Shortcut for getting a user defined value

public getUserValue(string $userId, string $key[, mixed $default = '' ]) : string
Parameters
$userId : string

the userId of the user that we want to store the value under

$key : string

the key under which the value is being stored

$default : mixed = ''

the default value to be returned if the value isn't set

Tags
since
20.0.0
Return values
string

hasAppKey()

Check if a key exists in the list of stored config values.

public hasAppKey(string $key[, bool $lazy = false ]) : bool
Parameters
$key : string

config key

$lazy : bool = false

search within lazy loaded config

Tags
since
29.0.0
Return values
bool

TRUE if key exists

isLazy()

Returns if the config key stored in database is lazy loaded

public isLazy(string $key) : bool

WARNING: ignore lazy filtering, all config values are loaded from database

Parameters
$key : string

config key

Tags
throws
AppConfigUnknownKeyException

if config key is not known

see
IAppConfig

for details about lazy loading

since
29.0.0
Return values
bool

TRUE if config is lazy loaded

isSensitive()

best way to see if a value is set as sensitive (not displayed in report)

public isSensitive(string $key[, bool|null $lazy = false ]) : bool
Parameters
$key : string

config key

$lazy : bool|null = false

search within lazy loaded config

Tags
throws
AppConfigUnknownKeyException

if config key is not known

since
29.0.0
Return values
bool

TRUE if value is sensitive

setAppValue()

Writes a new app wide value

public setAppValue(string $key, string $value) : void
Parameters
$key : string

the key of the value, under which will be saved

$value : string

the value that should be stored

Tags
since
20.0.0
deprecated
29.0.0

use setAppValueString()

setAppValueArray()

Store a config key and its value in database

public setAppValueArray(string $key, array<string|int, mixed> $value[, bool $lazy = false ][, bool $sensitive = false ]) : bool

If config key is already known with the exact same config value, the database is not updated. If config key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded.

If config value was previously stored as sensitive or lazy loaded, status cannot be altered without using deleteKey() first

Parameters
$key : string

config key

$value : array<string|int, mixed>

config value

$lazy : bool = false

set config as lazy loaded

$sensitive : bool = false

if TRUE value will be hidden when listing config values.

Tags
since
29.0.0
see
IAppConfig

for explanation about lazy loading

Return values
bool

TRUE if value was different, therefor updated in database

setAppValueBool()

Store a config key and its value in database

public setAppValueBool(string $key, bool $value[, bool $lazy = false ]) : bool

If config key is already known with the exact same config value, the database is not updated. If config key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded.

If config value was previously stored as lazy loaded, status cannot be altered without using deleteKey() first

Parameters
$key : string

config key

$value : bool

config value

$lazy : bool = false

set config as lazy loaded

Tags
since
29.0.0
see
IAppConfig

for explanation about lazy loading

Return values
bool

TRUE if value was different, therefor updated in database

setAppValueFloat()

Store a config key and its value in database.

public setAppValueFloat(string $key, float $value[, bool $lazy = false ][, bool $sensitive = false ]) : bool

If config key is already known with the exact same config value, the database is not updated. If config key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded.

If config value was previously stored as sensitive or lazy loaded, status cannot be altered without using deleteKey() first

Parameters
$key : string

config key

$value : float

config value

$lazy : bool = false

set config as lazy loaded

$sensitive : bool = false

if TRUE value will be hidden when listing config values.

Tags
since
29.0.0
see
IAppConfig

for explanation about lazy loading

Return values
bool

TRUE if value was different, therefor updated in database

setAppValueInt()

Store a config key and its value in database

public setAppValueInt(string $key, int $value[, bool $lazy = false ][, bool $sensitive = false ]) : bool

When handling huge value around and/or above 2,147,483,647, a debug log will be generated on 64bits system, as php int type reach its limit (and throw an exception) on 32bits when using huge numbers.

When using huge numbers, it is advised to use Util::numericToNumber() and setValueString()

If config key is already known with the exact same config value, the database is not updated. If config key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded.

If config value was previously stored as sensitive or lazy loaded, status cannot be altered without using deleteKey() first

Parameters
$key : string

config key

$value : int

config value

$lazy : bool = false

set config as lazy loaded

$sensitive : bool = false

if TRUE value will be hidden when listing config values.

Tags
since
29.0.0
see
IAppConfig

for explanation about lazy loading

Return values
bool

TRUE if value was different, therefor updated in database

setAppValueString()

Store a config key and its value in database

public setAppValueString(string $key, string $value[, bool $lazy = false ][, bool $sensitive = false ]) : bool

If config key is already known with the exact same config value, the database is not updated. If config key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded.

If config value was previously stored as sensitive or lazy loaded, status cannot be altered without using deleteKey() first

Parameters
$key : string

config key

$value : string

config value

$lazy : bool = false

set config as lazy loaded

$sensitive : bool = false

if TRUE value will be hidden when listing config values.

Tags
since
29.0.0
see
IAppConfig

for explanation about lazy loading

Return values
bool

TRUE if value was different, therefor updated in database

setUserValue()

Set a user defined value

public setUserValue(string $userId, string $key, string $value[, string $preCondition = null ]) : void
Parameters
$userId : string

the userId of the user that we want to store the value under

$key : string

the key under which the value is being stored

$value : string

the value that you want to store

$preCondition : string = null

only update if the config value was previously the value passed as $preCondition

Tags
throws
PreConditionNotMetException

if a precondition is specified and is not met

throws
UnexpectedValueException

when trying to store an unexpected value

since
20.0.0

        
On this page

Search results