The Hubzilla
 All Classes Namespaces Files Functions Variables Pages
Zotlabs\Lib\XConfig Class Reference

Class for handling observer's config. More...

Static Public Member Functions

static Load ($xchan)
 Loads a full xchan's configuration into a cached storage. More...
 
static Get ($xchan, $family, $key, $default=false)
 Get a particular observer's config variable given the category name ($family) and a key. More...
 
static Set ($xchan, $family, $key, $value)
 Sets a configuration value for an observer. More...
 
static Delete ($xchan, $family, $key)
 Deletes the given key from the observer's config. More...
 

Detailed Description

Class for handling observer's config.

XConfig is comparable to PConfig, except that it uses xchan (an observer hash) as an identifier.

XConfig is used for observer specific configurations and takes a xchan as identifier. The storage is of size MEDIUMTEXT.

$var = Zotlabs\Lib\XConfig::Get('xchan', 'category', 'key');
// with default value for non existent key
$var = Zotlabs\Lib\XConfig::Get('xchan', 'category', 'unsetkey', 'defaultvalue');

The old (deprecated?) way to access a XConfig value is:

$observer = App::get_observer_hash();
if ($observer) {
$var = get_xconfig($observer, 'category', 'key');
}

Member Function Documentation

static Zotlabs\Lib\XConfig::Delete (   $xchan,
  $family,
  $key 
)
static

Deletes the given key from the observer's config.

Removes the configured value from the stored cache in App::$config[$xchan] and removes it from the database.

Parameters
string$xchanThe observer's hash
string$familyThe category of the configuration value
string$keyThe configuration key to delete
Returns
mixed

Referenced by del_xconfig(), Zotlabs\Lib\AConfig\Delete(), and Zotlabs\Lib\SConfig\Delete().

static Zotlabs\Lib\XConfig::Get (   $xchan,
  $family,
  $key,
  $default = false 
)
static

Get a particular observer's config variable given the category name ($family) and a key.

Get a particular observer's config value from the given category ($family) and the $key from a cached storage in App::$config[$xchan].

Returns false if not set.

Parameters
string$xchanThe observer's hash
string$familyThe category of the configuration value
string$keyThe configuration key to query
boolean$default(optional) default false
Returns
mixed Stored $value or false if it does not exist

Referenced by Zotlabs\Lib\AConfig\Get(), Zotlabs\Lib\SConfig\Get(), and get_xconfig().

static Zotlabs\Lib\XConfig::Load (   $xchan)
static

Loads a full xchan's configuration into a cached storage.

All configuration values of the given observer hash are stored in global cache which is available under the global variable App::$config[$xchan].

Parameters
string$xchanThe observer's hash
Returns
void|false Returns false if xchan is not set

Referenced by Zotlabs\Lib\AConfig\Load(), Zotlabs\Lib\SConfig\Load(), and load_xconfig().

static Zotlabs\Lib\XConfig::Set (   $xchan,
  $family,
  $key,
  $value 
)
static

Sets a configuration value for an observer.

Stores a config value ($value) in the category ($family) under the key ($key) for the observer's $xchan hash.

Parameters
string$xchanThe observer's hash
string$familyThe category of the configuration value
string$keyThe configuration key to set
string$valueThe value to store
Returns
mixed Stored $value or false

Referenced by Zotlabs\Lib\AConfig\Set(), Zotlabs\Lib\SConfig\Set(), and set_xconfig().


The documentation for this class was generated from the following file: