class SettingsBag

Class SettingsBag

Properties

protected $domainId
protected $contactId
protected array $defaults
protected array $mandatory
protected array|NULL $combined The result of combining default values, mandatory values, and user values.
protected array $values

Methods

__construct(int $domainId, int|NULL $contactId)

No description

loadDefaults(array $defaults)

Set/replace the default values.

loadMandatory(array $mandatory)

Set/replace the mandatory values.

loadValues()

Load all explicit settings that apply to this domain or contact.

add(array $settings)

Add a batch of settings. Save them.

array
all()

Get a list of all effective settings.

mixed
get(string $key)

Determine the effective value.

mixed|NULL
getDefault(string $key)

Determine the default value of a setting.

mixed|NULL
getExplicit(string $key)

Determine the explicitly designated value, regardless of any default or mandatory values.

mixed|NULL
getMandatory(string $key)

Determine the mandatory value of a setting.

bool
hasExplict(string $key)

Determine if the entity has explicitly designated a value.

revert(string $key)

Removes any explicit settings. This restores the default.

set(string $key, mixed $value)

Add a single setting. Save it.

array
combine(array $arrays)

Combine a series of arrays, excluding any null values. Later values override earlier values.

setDb(string $name, mixed $value)

Update the DB record for this setting.

Details

at line 89
__construct(int $domainId, int|NULL $contactId)

Parameters

int $domainId The domain for which we want settings.
int|NULL $contactId The contact for which we want settings. Use NULL for domain settings.

at line 103
SettingsBag loadDefaults(array $defaults)

Set/replace the default values.

Parameters

array $defaults Array(string $settingName => mixed $value).

Return Value

SettingsBag

at line 116
SettingsBag loadMandatory(array $mandatory)

Set/replace the mandatory values.

Parameters

array $mandatory Array(string $settingName => mixed $value).

Return Value

SettingsBag

at line 127
SettingsBag loadValues()

Load all explicit settings that apply to this domain or contact.

Return Value

SettingsBag

at line 167
SettingsBag add(array $settings)

Add a batch of settings. Save them.

Parameters

array $settings Array(string $settingName => mixed $settingValue).

Return Value

SettingsBag

at line 180
array all()

Get a list of all effective settings.

Return Value

array Array(string $settingName => mixed $settingValue).

at line 195
mixed get(string $key)

Determine the effective value.

Parameters

string $key

Return Value

mixed

at line 207
mixed|NULL getDefault(string $key)

Determine the default value of a setting.

Parameters

string $key The simple name of the setting.

Return Value

mixed|NULL

at line 219
mixed|NULL getExplicit(string $key)

Determine the explicitly designated value, regardless of any default or mandatory values.

Parameters

string $key The simple name of the setting.

Return Value

mixed|NULL

at line 230
mixed|NULL getMandatory(string $key)

Determine the mandatory value of a setting.

Parameters

string $key The simple name of the setting.

Return Value

mixed|NULL

at line 244
bool hasExplict(string $key)

Determine if the entity has explicitly designated a value.

Note that get() may still return other values based on mandatory values or defaults.

Parameters

string $key The simple name of the setting.

Return Value

bool

at line 256
SettingsBag revert(string $key)

Removes any explicit settings. This restores the default.

Parameters

string $key The simple name of the setting.

Return Value

SettingsBag

at line 271
SettingsBag set(string $key, mixed $value)

Add a single setting. Save it.

Parameters

string $key The simple name of the setting.
mixed $value The new, explicit value of the setting.

Return Value

SettingsBag

at line 281
protected CRM_Utils_SQL_Select createQuery()

Return Value

CRM_Utils_SQL_Select

at line 308
protected array combine(array $arrays)

Combine a series of arrays, excluding any null values. Later values override earlier values.

Parameters

array $arrays List of arrays to combine.

Return Value

array

at line 328
protected setDb(string $name, mixed $value)

Update the DB record for this setting.

Parameters

string $name The simple name of the setting.
mixed $value The new value of the setting.