SettingsManager
in package
Class SettingsManager
Tags
Table of Contents
Constants
- BOOT_PHASE_COMPLETE = 2
- BOOT_PHASE_EARLY = 0
- BOOT_PHASE_MID = 1
Properties
- $bagsByContact : array<string|int, mixed>
- $bagsByDomain : array<string|int, mixed>
- $bootPhase : int
- The SettingsManager boots through 3 phases:
- $cache : CRM_Utils_Cache_Interface
- $mandatory : array<string|int, mixed>|null
Methods
- __construct() : mixed
- bootComplete() : SettingsManager
- Remove pre-boot restrictions and reload defaults/mandatory
- bootSettings() : mixed
- Load boot settings from environment and/or settings file
- dbAvailable() : SettingsManager
- Signal that the SettingsManager can now load values from the DB
- flush() : SettingsManager
- Flush all in-memory and persistent caches related to settings.
- getBagByContact() : SettingsBag
- Get Settings by contact.
- getBagByDomain() : SettingsBag
- Get Settings by domain.
- parseMandatorySettingsGlobalVar() : array<string|int, mixed>
- Parse mandatory settings from global env var.
- useDefaults() : SettingsManager
- Maintained as public alias of bootComplete for compatibility
- useMandatory() : SettingsManager
- Ensure that mandatory values are included with all current and future bags.
- getDefaults() : array<string|int, mixed>
- Determine the default settings.
- getEnvSettingValues() : array<string|int, mixed>
- Get any setting values set using environment variables
- getMandatory() : array<string|int, mixed>
- Get a list of mandatory/overriden settings from $civicrm_setting global or environment.
- reloadDefaults() : SettingsManager
- (Re)load default values for all existing settings bags
- reloadValues() : SettingsManager
- (Re)load database values for all existing settings bags
Constants
BOOT_PHASE_COMPLETE
protected
mixed
BOOT_PHASE_COMPLETE
= 2
BOOT_PHASE_EARLY
protected
mixed
BOOT_PHASE_EARLY
= 0
BOOT_PHASE_MID
protected
mixed
BOOT_PHASE_MID
= 1
Properties
$bagsByContact
protected
array<string|int, mixed>
$bagsByContact
= []
Array (int $id => SettingsBag $bag).
$bagsByDomain
protected
array<string|int, mixed>
$bagsByDomain
= []
Array (int $id => SettingsBag $bag).
$bootPhase
The SettingsManager boots through 3 phases:
protected
int
$bootPhase
= self::BOOT_PHASE_EARLY
-
during early boot, we load metadata for a limited subset of settings in core *.boot.setting.php files. Setting values come only from environment variables, $civicrm_setting global, or default
-
once the database is loaded, we can load database values
-
once the extension system is booted, we have full and final settings metadata (including from extensions)
$cache
protected
CRM_Utils_Cache_Interface
$cache
$mandatory
protected
array<string|int, mixed>|null
$mandatory
= NULL
Array(string $entity => array(string $settingName => mixed $value)). Ex: $mandatory['domain']['uploadDir']. NULL means "autoload from $civicrm_setting".
Methods
__construct()
public
__construct(CRM_Utils_Cache_Interface $cache) : mixed
Parameters
- $cache : CRM_Utils_Cache_Interface
-
A semi-durable location to store metadata.
bootComplete()
Remove pre-boot restrictions and reload defaults/mandatory
public
bootComplete() : SettingsManager
Return values
SettingsManagerbootSettings()
Load boot settings from environment and/or settings file
public
static bootSettings(string $settingsPath) : mixed
Parameters
- $settingsPath : string
-
Path to the civicrm.settings.php file
dbAvailable()
Signal that the SettingsManager can now load values from the DB
public
dbAvailable() : SettingsManager
Return values
SettingsManagerflush()
Flush all in-memory and persistent caches related to settings.
public
flush() : SettingsManager
Return values
SettingsManagergetBagByContact()
Get Settings by contact.
public
getBagByContact(int|null $domainId, int|null $contactId) : SettingsBag
Parameters
- $domainId : int|null
-
For the default domain, leave $domainID as NULL.
- $contactId : int|null
-
For the default/active user's contact, leave $domainID as NULL.
Tags
Return values
SettingsBaggetBagByDomain()
Get Settings by domain.
public
getBagByDomain(int|null $domainId) : SettingsBag
Parameters
- $domainId : int|null
Return values
SettingsBagparseMandatorySettingsGlobalVar()
Parse mandatory settings from global env var.
public
static parseMandatorySettingsGlobalVar(array<string|int, mixed> $civicrm_setting) : array<string|int, mixed>
In previous versions, settings were broken down into verbose+dynamic group names, e.g.
$civicrm_settings['Foo Bar Preferences']['foo'] = 'bar';
We now simplify to two simple groups, 'domain' and 'contact'.
$civicrm_settings['domain']['foo'] = 'bar';
'Personal Preferences' is still aliased for compatibility (is this still needed in June 2024?).
Parameters
- $civicrm_setting : array<string|int, mixed>
-
Ex: $civicrm_setting['Group Name']['field'] = 'value'. Group names are an historical quirk; ignore them.
Return values
array<string|int, mixed>useDefaults()
Maintained as public alias of bootComplete for compatibility
public
useDefaults() : SettingsManager
Return values
SettingsManageruseMandatory()
Ensure that mandatory values are included with all current and future bags.
public
useMandatory() : SettingsManager
If you call useMandatory multiple times, it will re-scan the global $civicrm_setting and environment variables
Return values
SettingsManagergetDefaults()
Determine the default settings.
protected
getDefaults(string $entity) : array<string|int, mixed>
Parameters
- $entity : string
-
Ex: 'domain' or 'contact'.
Return values
array<string|int, mixed> —Array(string $settingName => mixed $value).
getEnvSettingValues()
Get any setting values set using environment variables
protected
getEnvSettingValues(string $entity) : array<string|int, mixed>
Parameters
- $entity : string
-
Ex: 'domain' or 'contact'.
Return values
array<string|int, mixed> —Array(string $settingName or $settingFqn => mixed $value).
getMandatory()
Get a list of mandatory/overriden settings from $civicrm_setting global or environment.
protected
getMandatory(string $entity) : array<string|int, mixed>
Parameters
- $entity : string
-
Ex: 'domain' or 'contact'.
Return values
array<string|int, mixed> —Array(string $settingName => mixed $value).
reloadDefaults()
(Re)load default values for all existing settings bags
protected
reloadDefaults() : SettingsManager
Return values
SettingsManagerreloadValues()
(Re)load database values for all existing settings bags
protected
reloadValues() : SettingsManager