PHP Класс Habari\Options

Наследование: extends Singleton
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__get ( string $name ) : mixed Retrieve an option value
__isset ( $name )
__set ( string $name, mixed $value ) Applies the option value to the options table
__unset ( string $name ) Removes an option from the options table
clear_cache ( ) Clears memory of cached options
delete ( string | array $name ) Shortcut to unset an option in the options table
delete_group ( string $prefix ) Delete a group of options with a specific prefix
get ( string | array $name, mixed $default_value = null ) : mixed Shortcut to return the value of an option
get_all_options ( ) Fetch all options from the options table into local storage
get_group ( string $prefix ) : array Fetch a group of options with a specific prefix Useful for plugins that use FormUI to automatically store options with the plugin's prefix.
is_static ( string $name ) : boolean Check if an option was set via the config, making it unsettable
out ( string $name ) Shortcut to output the value of an option
set ( string | array $name, mixed $value = '' ) function set Shortcut to set the value of an option
set_group ( string $prefix, array $values ) Set a group of options with a specific prefix

Защищенные методы

Метод Описание
instance ( ) Enables singleton working properly

Описание методов

__get() публичный Метод

Retrieve an option value
public __get ( string $name ) : mixed
$name string Name of the option to get
Результат mixed Stored value for specified option

__isset() публичный Метод

public __isset ( $name )

__set() публичный Метод

Applies the option value to the options table
public __set ( string $name, mixed $value )
$name string Name of the option to set
$value mixed Value to set

__unset() публичный Метод

Removes an option from the options table
public __unset ( string $name )
$name string The name of the option

clear_cache() публичный статический Метод

Clears memory of cached options
public static clear_cache ( )

delete() публичный статический Метод

Shortcut to unset an option in the options table
public static delete ( string | array $name )
$name string | array The name of the option or an array of names to delete.

delete_group() публичный статический Метод

Options::delete_group( 'foo' ); would delete all foo__* option names
public static delete_group ( string $prefix )
$prefix string The prefix to delete

get() публичный статический Метод

$foo = Options::get('foo'); // returns null if the option 'foo' does not exist list($foo, $bar, $baz) = Options::get( array('foo1', 'bar2', 'baz3') ); // useful with array_keys() $bar = Options::get('foo', 'bar'); // returns 'bar' if the option 'foo' does not exist. useful for avoiding if/then blocks to detect unset options
public static get ( string | array $name, mixed $default_value = null ) : mixed
$name string | array The name or an array of names of the option to fetch.
$default_value mixed The value to return for an option if it does not exist.
Результат mixed The option requested or an array of requested options, $default_value for each if the option does not exist

get_all_options() публичный Метод

Fetch all options from the options table into local storage
public get_all_options ( )

get_group() публичный статический Метод

Fetch a group of options with a specific prefix Useful for plugins that use FormUI to automatically store options with the plugin's prefix.
public static get_group ( string $prefix ) : array
$prefix string The prefix to fetch
Результат array An associative array of all options with that prefix

instance() защищенный статический Метод

Enables singleton working properly
protected static instance ( )

is_static() публичный статический Метод

Check if an option was set via the config, making it unsettable
public static is_static ( string $name ) : boolean
$name string The name of the option to check
Результат boolean True if the option is set in the config

out() публичный статический Метод

Options::out('foo');
public static out ( string $name )
$name string Name of the option to output

set() публичный статический Метод

Options::set('foo', 'newvalue'); Options::set( array( 'foo' => 'bar', 'baz' => 'qux' ) );
public static set ( string | array $name, mixed $value = '' )
$name string | array Name of the option to set or an array of name => value options to set.
$value mixed New value of the option to store. If first parameter is an array, $value is ignored.

set_group() публичный статический Метод

Options::set_group( 'foo', array( 'bar' => 'baz', 'qux' => 'quux' ) ); results in 2 options: foo__bar == baz and foo__qux == quux
public static set_group ( string $prefix, array $values )
$prefix string The prefix to set
$values array An associative array of all options to be set with that prefix