Krang::Pref - Krang Global Preference API
use Krang::ClassLoader 'Pref';
# get the value set 'search_page_size', a scalar preference
$page_size = pkg('Pref')->get('search_page_size');
# get a hash of ids to names for a list preference
%data = pkg('Pref')->get('contrib_type');
# set a scalar preference
pkg('Pref')->set(search_page_size => 10);
# set a list preference with a list of ids and names
pkg('Pref')->set(contrib_type => 1 => 'Writer', 2 => 'Photographer');
Krang::Pref provides a means for the user to access and change configurable settings.
There are two types of Preferences: scalars and lists. A scalar preference accepts a single value. A list preference contains a list of values, identified by unique IDs mapping to names.
The following preferenes are supported by Krang::Pref:
New preferences can be added by editing the configuration data in this module.
$opt_id = Krang::Pref->add_option($list_pref_name, $new_pref_opt)If no value has been configured for the preference then nothing is returned (undef in scalar context, empty list in list context).
Note that this method does not do any dependency checking on values being removed from the table.