CRM_Admin_Form_SettingTrait
This trait allows us to consolidate Preferences & Settings forms.
It is intended mostly as part of a refactoring process to get rid of having 2.
Table of Contents
Properties
- $readOnlyFields : array<string|int, mixed>
- Fields defined as read only.
- $settingsMetadata : array<string|int, mixed>
- $_filter : string
- The setting page filter.
Methods
- getDefaultEntity() : string
- Get default entity.
- getSettingPageFilter() : string
- This is public so we can retrieve the filter name via hooks etc. and apply conditional logic (eg. loading javascript conditionals).
- reorderSortableOptions() : array<string|int, mixed>
- Display options in correct order on the form
- addFieldsDefinedInSettingsMetadata() : mixed
- Add fields in the metadata to the template.
- addSettingsToFormFromMetadata() : mixed
- Add settings to form if the metadata designates they should be on the page.
- filterMetadataByWeight() : array<string|int, mixed>
- filterParamsSetByMetadata() : mixed
- getQuickFormType() : string
- Get the quickform type for the given html type.
- getSettingMetadata() : mixed
- Get the metadata for a particular field.
- getSettingMetadataItem() : mixed
- Get the metadata for a particular field for a particular item.
- getSettingsMetaData() : array<string|int, mixed>
- Get the metadata relating to the settings on the form, ordered by the keys in $this->_settings.
- getSettingsOrderedByWeight() : array<string|int, mixed>
- Returns a re-keyed copy of the settings, ordered by weight.
- getSettingsToSetByMetadata() : array<string|int, mixed>
- Get the settings which can be stored based on metadata.
- hasReadOnlyFields() : bool
- Have read only fields been defined on the form.
- isWeightHigher() : int
- Is the relevant weight of b higher than a.
- saveMetadataDefinedSettings() : mixed
- Save any fields which have been defined via metadata.
- setDefaultsForMetadataDefinedFields() : mixed
- Get the defaults for all fields defined in the metadata.
- getReorderedSettingData() : array<string|int, mixed>
Properties
$readOnlyFields
Fields defined as read only.
protected
array<string|int, mixed>
$readOnlyFields
= []
$settingsMetadata
protected
array<string|int, mixed>
$settingsMetadata
$_filter
The setting page filter.
private
string
$_filter
Methods
getDefaultEntity()
Get default entity.
public
getDefaultEntity() : string
Return values
stringgetSettingPageFilter()
This is public so we can retrieve the filter name via hooks etc. and apply conditional logic (eg. loading javascript conditionals).
public
getSettingPageFilter() : string
Return values
stringreorderSortableOptions()
Display options in correct order on the form
public
static reorderSortableOptions(mixed $setting, mixed $options) : array<string|int, mixed>
Parameters
- $setting : mixed
- $options : mixed
Return values
array<string|int, mixed>addFieldsDefinedInSettingsMetadata()
Add fields in the metadata to the template.
protected
addFieldsDefinedInSettingsMetadata() : mixed
Tags
addSettingsToFormFromMetadata()
Add settings to form if the metadata designates they should be on the page.
protected
addSettingsToFormFromMetadata() : mixed
Tags
filterMetadataByWeight()
protected
filterMetadataByWeight(array<string|int, mixed> $settingMetaData) : array<string|int, mixed>
Parameters
- $settingMetaData : array<string|int, mixed>
Return values
array<string|int, mixed>filterParamsSetByMetadata()
protected
filterParamsSetByMetadata(mixed &$params) : mixed
Parameters
- $params : mixed
getQuickFormType()
Get the quickform type for the given html type.
protected
getQuickFormType(array<string|int, mixed> $spec) : string
Parameters
- $spec : array<string|int, mixed>
Return values
stringgetSettingMetadata()
Get the metadata for a particular field.
protected
getSettingMetadata(mixed $setting) : mixed
Parameters
- $setting : mixed
getSettingMetadataItem()
Get the metadata for a particular field for a particular item.
protected
getSettingMetadataItem(mixed $setting, mixed $item) : mixed
e.g get 'serialize' key, if exists, for a field.
Parameters
- $setting : mixed
- $item : mixed
getSettingsMetaData()
Get the metadata relating to the settings on the form, ordered by the keys in $this->_settings.
protected
getSettingsMetaData() : array<string|int, mixed>
Return values
array<string|int, mixed>getSettingsOrderedByWeight()
Returns a re-keyed copy of the settings, ordered by weight.
protected
getSettingsOrderedByWeight() : array<string|int, mixed>
Return values
array<string|int, mixed>getSettingsToSetByMetadata()
Get the settings which can be stored based on metadata.
protected
getSettingsToSetByMetadata(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed>
Return values
array<string|int, mixed>hasReadOnlyFields()
Have read only fields been defined on the form.
protected
hasReadOnlyFields() : bool
Return values
boolisWeightHigher()
Is the relevant weight of b higher than a.
protected
isWeightHigher(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
- $a : array<string|int, mixed>
- $b : array<string|int, mixed>
Return values
intsaveMetadataDefinedSettings()
Save any fields which have been defined via metadata.
protected
saveMetadataDefinedSettings(array<string|int, mixed> $params) : mixed
(Other fields are hack-handled... sadly.
Parameters
- $params : array<string|int, mixed>
-
Form input.
Tags
setDefaultsForMetadataDefinedFields()
Get the defaults for all fields defined in the metadata.
protected
setDefaultsForMetadataDefinedFields() : mixed
All others are pending conversion.
Tags
getReorderedSettingData()
private
getReorderedSettingData(string $setting, array<string|int, mixed> $settingValue) : array<string|int, mixed>
Parameters
- $setting : string
- $settingValue : array<string|int, mixed>