Documentation

Horde_Prefs
in package
implements ArrayAccess

The Horde_Prefs class provides a common abstracted interface into the various preferences storage mediums.

It also includes all of the functions for retrieving, storing, and checking preference values.

Tags
author

Jon Parise jon@horde.org

category

Horde

license

http://www.horde.org/licenses/lgpl21 LGPL 2.1

Interfaces, Classes, Traits and Enums

ArrayAccess

Table of Contents

DEFAULT_SCOPE  = 'horde'
$_cache  : Horde_Prefs_Cache
Caching object.
$_opts  : array<string|int, mixed>
General library options.
$_scope  : string
String containing the name of the current scope. This is used to differentiate between sets of preferences. By default, preferences belong to this scope.
$_scopes  : array<string|int, mixed>
Scope list. Keys are scope names, values are Horde_Prefs_Scope objects.
$_storage  : array<string|int, mixed>
The storage driver(s).
__construct()  : mixed
Constructor.
__get()  : mixed
Shortcut to getValue().
__set()  : mixed
Shortcut to setValue().
changeScope()  : mixed
Changes the current preference scope.
cleanup()  : mixed
Cleanup (e.g. remove) scope(s).
getCache()  : Horde_Prefs_Cache_Base
Return the cache object.
getDefault()  : string
Returns the default value of the given preference.
getScope()  : string
Get the current scope.
getScopeObject()  : Horde_Prefs_Scope
Returns the current scope object.
getStorage()  : array<string|int, mixed>
Returns the storage drivers.
getUser()  : string
Return the user who owns these preferences.
getValue()  : string
Returns the value of the requested preference.
isDefault()  : bool
Determines if the current preference value is the default value.
isDirty()  : bool
Is a preference marked dirty?
isLocked()  : bool
Is a preference locked?
offsetExists()  : mixed
offsetGet()  : mixed
offsetSet()  : mixed
offsetUnset()  : mixed
remove()  : mixed
Removes a preference entry from the $prefs hash.
removeAll()  : mixed
Removes all preference entries for the current user from the $prefs hash and the backends.
retrieve()  : mixed
Retrieves preferences for the current scope.
setLocked()  : mixed
Mark a preference as locked.
setValue()  : bool
Sets the given preference to the specified value if the preference is modifiable.
store()  : mixed
Save all dirty prefs to the storage backend.
_getScope()  : mixed
Returns the scope of a preference.
_loadScope()  : mixed
Load a specific preference scope.

Constants

DEFAULT_SCOPE

public mixed DEFAULT_SCOPE = 'horde'

Properties

$_cache

Caching object.

protected Horde_Prefs_Cache $_cache

$_opts

General library options.

protected array<string|int, mixed> $_opts = array('cache' => \null, 'logger' => \null, 'sizecallback' => \null, 'storage' => \null, 'user' => '')

$_scope

String containing the name of the current scope. This is used to differentiate between sets of preferences. By default, preferences belong to this scope.

protected string $_scope = self::DEFAULT_SCOPE

$_scopes

Scope list. Keys are scope names, values are Horde_Prefs_Scope objects.

protected array<string|int, mixed> $_scopes = array()

$_storage

The storage driver(s).

protected array<string|int, mixed> $_storage

Methods

__construct()

Constructor.

public __construct(string $scope[, mixed $storage = null ][, array<string|int, mixed> $opts = array() ]) : mixed
Parameters
$scope : string

The scope for this set of preferences.

$storage : mixed = null

The storage object(s) to use. Either a single Horde_Prefs_Storage object, or an array of objects.

$opts : array<string|int, mixed> = array()

Additional confguration options:

cache - (Horde_Prefs_Cache) The cache driver to use.
        DEFAULT: No caching.
logger - (Horde_Log_Logger) Logging object.
         DEFAULT: NONE
sizecallback - (callback) If set, called when setting a value in the
               backend.
               DEFAULT: NONE
user - (string) The name of the user who owns this set of preferences.
       DEFAULT: NONE
Return values
mixed —

__get()

Shortcut to getValue().

public __get(mixed $name) : mixed
Parameters
$name : mixed
Return values
mixed —

__set()

Shortcut to setValue().

public __set(mixed $name, mixed $value) : mixed
Parameters
$name : mixed
$value : mixed
Return values
mixed —

changeScope()

Changes the current preference scope.

public changeScope(string $scope) : mixed
Parameters
$scope : string

Scope specifier.

Tags
since
2.6.0
Return values
mixed —

cleanup()

Cleanup (e.g. remove) scope(s).

public cleanup([bool $all = false ]) : mixed
Parameters
$all : bool = false

Cleanup all scopes. If false, clean present scope only.

Return values
mixed —

getDefault()

Returns the default value of the given preference.

public getDefault(string $pref) : string
Parameters
$pref : string

The name of the preference to get the default for.

Return values
string —

The preference's default value.

getScope()

Get the current scope.

public getScope() : string
Return values
string —

The current scope (application).

getScopeObject()

Returns the current scope object.

public getScopeObject([mixed $scope = null ]) : Horde_Prefs_Scope
Parameters
$scope : mixed = null
Tags
since
2.9.0
Return values
Horde_Prefs_Scope —

The current scope object.

getStorage()

Returns the storage drivers.

public getStorage() : array<string|int, mixed>
Return values
array<string|int, mixed> —

The storage drivers.

getUser()

Return the user who owns these preferences.

public getUser() : string
Return values
string —

The user these preferences are for.

getValue()

Returns the value of the requested preference.

public getValue(string $pref) : string
Parameters
$pref : string

The preference name.

Return values
string —

The value of the preference (UTF-8), null if it doesn't exist.

isDefault()

Determines if the current preference value is the default value.

public isDefault(string $pref) : bool
Parameters
$pref : string

The name of the preference to check.

Return values
bool —

True if the preference is the application default value.

isDirty()

Is a preference marked dirty?

public isDirty(string $pref) : bool
Parameters
$pref : string

The preference name.

Return values
bool —

True if the preference is marked dirty.

isLocked()

Is a preference locked?

public isLocked(string $pref) : bool
Parameters
$pref : string

The preference name.

Return values
bool —

Whether the preference is locked.

offsetExists()

public offsetExists(mixed $offset) : mixed
Parameters
$offset : mixed
Return values
mixed —

offsetGet()

public offsetGet(mixed $offset) : mixed
Parameters
$offset : mixed
Return values
mixed —

offsetSet()

public offsetSet(mixed $offset, mixed $value) : mixed
Parameters
$offset : mixed
$value : mixed
Return values
mixed —

offsetUnset()

public offsetUnset(mixed $offset) : mixed
Parameters
$offset : mixed
Return values
mixed —

remove()

Removes a preference entry from the $prefs hash.

public remove([string $pref = null ]) : mixed
Parameters
$pref : string = null

The name of the preference to remove. If null, removes all preferences from the current scope.

Return values
mixed —

removeAll()

Removes all preference entries for the current user from the $prefs hash and the backends.

public removeAll() : mixed
Tags
since

Horde_Prefs 2.8.0

throws
Horde_Prefs_Exception
Return values
mixed —

retrieve()

Retrieves preferences for the current scope.

public retrieve([string $scope = null ]) : mixed
Parameters
$scope : string = null

Optional scope specifier - if not present the current scope will be used.

Return values
mixed —

setLocked()

Mark a preference as locked.

public setLocked(string $pref, mixed $bool) : mixed
Parameters
$pref : string

The preference name.

$bool : mixed
Return values
mixed —

setValue()

Sets the given preference to the specified value if the preference is modifiable.

public setValue(string $pref, string $val[, array<string|int, mixed> $opts = array() ]) : bool
Parameters
$pref : string

The preference name to modify.

$val : string

The preference value (UTF-8).

$opts : array<string|int, mixed> = array()

Additional options:

  - force: (boolean) If true, will set the value disregarding the
           current locked status of the pref. (@since 2.5.0)
           DEFAULT: false
  - nosave: (boolean) If true, the preference will not be saved to the
            storage backend(s).
            DEFAULT: false
Tags
throws
Horde_Prefs_Exception
Return values
bool —

True if the value was successfully set, false on a failure.

store()

Save all dirty prefs to the storage backend.

public store([bool $throw = true ]) : mixed
Parameters
$throw : bool = true

Throw exception on error? If false, ignores errors. (Since 2.1.0)

Return values
mixed —

_getScope()

Returns the scope of a preference.

protected _getScope(string $pref) : mixed
Parameters
$pref : string

The preference name.

Return values
mixed —

The scope of the preference, or null if it doesn't exist.

_loadScope()

Load a specific preference scope.

protected _loadScope(string $scope) : mixed
Parameters
$scope : string

The scope to load.

Return values
mixed —

Search results