PHP Class Habari\ControlStorage

Inheritance: implements habari\FormStorage
Show file Open project: habari/system

Protected Properties

Property Type Description
$loader Callable | string A function that loads this control value
$saver Callable | string A fucntion that saves this control value

Public Methods

Method Description
__construct ( Callable | string $load, $save ) Construct a basic FormStorage object
field_load ( string $key ) : mixed Loads form values from an object
field_save ( string $key, mixed $value ) Stores a form value into the object
from_object_parameter ( Object $obj, string $parameter ) : ControlStorage Create a new ControlStorage instance to save/load a control value from the parameter of a particular object
from_storage_string ( string $value ) : ControlStorage Produce a basic FormStorage implementation from a classic storage string

Method Details

__construct() public method

Construct a basic FormStorage object
public __construct ( Callable | string $load, $save )
$load Callable | string A function to call to load the control value, OR a non-callable
$save

field_load() public method

Loads form values from an object
public field_load ( string $key ) : mixed
$key string The name of a form component that will be loaded
return mixed The stored value returned

field_save() public method

Stores a form value into the object
public field_save ( string $key, mixed $value )
$key string The name of a form component that will be stored
$value mixed The value of the form component to store

from_object_parameter() public method

Create a new ControlStorage instance to save/load a control value from the parameter of a particular object
public from_object_parameter ( Object $obj, string $parameter ) : ControlStorage
$obj Object The object that will be saved to or loaded from
$parameter string The name of a parameter on the object that will be used for storage
return ControlStorage An instance of a ControlStorage object that will load/save to the specified location

from_storage_string() public static method

Produce a basic FormStorage implementation from a classic storage string
public static from_storage_string ( string $value ) : ControlStorage
$value string A classic storage string, such as "option:someoption" or "user:age"
return ControlStorage An instance of an object that will save and load to the indicated location

Property Details

$loader protected property

A function that loads this control value
protected Callable|string $loader
return Callable | string

$saver protected property

A fucntion that saves this control value
protected Callable|string $saver
return Callable | string