PHP Class Horde_Prefs, horde

It also includes all of the functions for retrieving, storing, and checking preference values.
Author: Jon Parise ([email protected])
Inheritance: implements ArrayAccess
Mostra file Open project: horde/horde Class Usage Examples

Protected Properties

Property Type Description
$_cache Horde_Prefs_Cache Caching object.
$_opts array 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 Scope list. Keys are scope names, values are Horde_Prefs_Scope objects.
$_storage array The storage driver(s).

Public Methods

Method Description
__construct ( string $scope, mixed $storage = null, array $opts = [] ) Constructor.
__get ( $name ) Shortcut to getValue().
__set ( $name, $value ) Shortcut to setValue().
changeScope ( string $scope ) Changes the current preference scope.
cleanup ( boolean $all = false ) Cleanup (e.g. remove) scope(s).
getCache ( ) : Horde_Prefs_Cache_Base Return the cache object.
getDefault ( string $pref ) : string Returns the default value of the given preference.
getScope ( ) : string Get the current scope.
getStorage ( ) : array Returns the storage drivers.
getUser ( ) : string Return the user who owns these preferences.
getValue ( string $pref ) : string Returns the value of the requested preference.
isDefault ( string $pref ) : boolean Determines if the current preference value is the default value.
isDirty ( string $pref ) : boolean Is a preference marked dirty?
isLocked ( string $pref ) : boolean Is a preference locked?
offsetExists ( $offset ) * ArrayAccess methods.
offsetGet ( $offset )
offsetSet ( $offset, $value )
offsetUnset ( $offset )
remove ( string $pref = null ) Removes a preference entry from the $prefs hash.
removeAll ( ) Removes all preference entries for the current user from the $prefs hash and the backends.
retrieve ( string $scope = null ) Retrieves preferences for the current scope.
setLocked ( string $pref, $bool ) Mark a preference as locked.
setValue ( string $pref, string $val, array $opts = [] ) : boolean Sets the given preference to the specified value if the preference is modifiable.
store ( boolean $throw = true ) Save all dirty prefs to the storage backend.

Protected Methods

Method Description
_getScope ( string $pref ) : mixed Returns the scope of a preference.
_loadScope ( string $scope ) Load a specific preference scope.

Method Details

__construct() public method

Constructor.
public __construct ( string $scope, mixed $storage = null, array $opts = [] )
$scope string The scope for this set of preferences.
$storage mixed The storage object(s) to use. Either a single Horde_Prefs_Storage object, or an array of objects.
$opts 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

__get() public method

Shortcut to getValue().
public __get ( $name )

__set() public method

Shortcut to setValue().
public __set ( $name, $value )

_getScope() protected method

Returns the scope of a preference.
protected _getScope ( string $pref ) : mixed
$pref string The preference name.
return mixed The scope of the preference, or null if it doesn't exist.

_loadScope() protected method

Load a specific preference scope.
protected _loadScope ( string $scope )
$scope string The scope to load.

changeScope() public method

Changes the current preference scope.
Since: 2.6.0
public changeScope ( string $scope )
$scope string Scope specifier.

cleanup() public method

Cleanup (e.g. remove) scope(s).
public cleanup ( boolean $all = false )
$all boolean Cleanup all scopes. If false, clean present scope only.

getCache() public method

Return the cache object.
Since: 2.6.0
public getCache ( ) : Horde_Prefs_Cache_Base
return Horde_Prefs_Cache_Base Cache object.

getDefault() public method

Returns the default value of the given preference.
public getDefault ( string $pref ) : string
$pref string The name of the preference to get the default for.
return string The preference's default value.

getScope() public method

Get the current scope.
public getScope ( ) : string
return string The current scope (application).

getStorage() public method

Returns the storage drivers.
public getStorage ( ) : array
return array The storage drivers.

getUser() public method

Return the user who owns these preferences.
public getUser ( ) : string
return string The user these preferences are for.

getValue() public method

Returns the value of the requested preference.
public getValue ( string $pref ) : string
$pref string The preference name.
return string The value of the preference (UTF-8), null if it doesn't exist.

isDefault() public method

Determines if the current preference value is the default value.
public isDefault ( string $pref ) : boolean
$pref string The name of the preference to check.
return boolean True if the preference is the application default value.

isDirty() public method

Is a preference marked dirty?
public isDirty ( string $pref ) : boolean
$pref string The preference name.
return boolean True if the preference is marked dirty.

isLocked() public method

Is a preference locked?
public isLocked ( string $pref ) : boolean
$pref string The preference name.
return boolean Whether the preference is locked.

offsetExists() public method

* ArrayAccess methods.
public offsetExists ( $offset )

offsetGet() public method

public offsetGet ( $offset )

offsetSet() public method

public offsetSet ( $offset, $value )

offsetUnset() public method

public offsetUnset ( $offset )

remove() public method

Removes a preference entry from the $prefs hash.
public remove ( string $pref = null )
$pref string The name of the preference to remove. If null, removes all preferences from the current scope.

removeAll() public method

Removes all preference entries for the current user from the $prefs hash and the backends.
public removeAll ( )

retrieve() public method

Retrieves preferences for the current scope.
public retrieve ( string $scope = null )
$scope string Optional scope specifier - if not present the current scope will be used.

setLocked() public method

Mark a preference as locked.
public setLocked ( string $pref, $bool )
$pref string The preference name.

setValue() public method

Sets the given preference to the specified value if the preference is modifiable.
public setValue ( string $pref, string $val, array $opts = [] ) : boolean
$pref string The preference name to modify.
$val string The preference value (UTF-8).
$opts 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
return boolean True if the value was successfully set, false on a failure.

store() public method

Save all dirty prefs to the storage backend.
public store ( boolean $throw = true )
$throw boolean Throw exception on error? If false, ignores errors. (Since 2.1.0)

Property Details

$_cache protected_oe property

Caching object.
protected Horde_Prefs_Cache $_cache
return Horde_Prefs_Cache

$_opts protected_oe property

General library options.
protected array $_opts
return array

$_scope protected_oe property

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
return string

$_scopes protected_oe property

Scope list. Keys are scope names, values are Horde_Prefs_Scope objects.
protected array $_scopes
return array

$_storage protected_oe property

The storage driver(s).
protected array $_storage
return array