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
Afficher le fichier Open project: horde/horde Class Usage Examples

Protected Properties

Свойство 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).

Méthodes publiques

Méthode 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.

Méthodes protégées

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

Method Details

__construct() public méthode

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 méthode

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

__set() public méthode

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

_getScope() protected méthode

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

_loadScope() protected méthode

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

changeScope() public méthode

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

cleanup() public méthode

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

getCache() public méthode

Return the cache object.
Since: 2.6.0
public getCache ( ) : Horde_Prefs_Cache_Base
Résultat Horde_Prefs_Cache_Base Cache object.

getDefault() public méthode

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.
Résultat string The preference's default value.

getScope() public méthode

Get the current scope.
public getScope ( ) : string
Résultat string The current scope (application).

getStorage() public méthode

Returns the storage drivers.
public getStorage ( ) : array
Résultat array The storage drivers.

getUser() public méthode

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

getValue() public méthode

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

isDefault() public méthode

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

isDirty() public méthode

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

isLocked() public méthode

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

offsetExists() public méthode

* ArrayAccess methods.
public offsetExists ( $offset )

offsetGet() public méthode

public offsetGet ( $offset )

offsetSet() public méthode

public offsetSet ( $offset, $value )

offsetUnset() public méthode

public offsetUnset ( $offset )

remove() public méthode

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 méthode

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

retrieve() public méthode

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 méthode

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

setValue() public méthode

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
Résultat boolean True if the value was successfully set, false on a failure.

store() public méthode

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
Résultat Horde_Prefs_Cache

$_opts protected_oe property

General library options.
protected array $_opts
Résultat 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
Résultat string

$_scopes protected_oe property

Scope list. Keys are scope names, values are Horde_Prefs_Scope objects.
protected array $_scopes
Résultat array

$_storage protected_oe property

The storage driver(s).
protected array $_storage
Résultat array