PHP 클래스 Habari\Options

상속: extends Singleton
파일 보기 프로젝트 열기: habari/system 1 사용 예제들

공개 메소드들

메소드 설명
__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