class CRM_Core_OptionGroup

Properties

static $_values
static $_cache
static $_domainIDGroups $_domainIDGroups array maintains the list of option groups for whom domainID is to be considered.

Methods

static array
valuesCommon(CRM_Core_DAO $dao, bool $flip = FALSE, bool $grouping = FALSE, bool $localize = FALSE, string $valueColumnName = 'label')

No description

static array
values(string $name, bool $flip = FALSE, bool $grouping = FALSE, bool $localize = FALSE, string $condition = NULL, string $labelColumnName = 'label', bool $onlyActive = TRUE, bool $fresh = FALSE, string $keyColumnName = 'value', string $orderBy = 'weight')

This function retrieves all the values for the specific option group by name this is primarily used to create various html based form elements (radio, select, checkbox etc). OptionGroups for most cases have the 'label' in the label column and the 'id' or 'name' in the value column

static 
flushValues(string $name, $flip, $grouping, $localize, $condition, string $labelColumnName, $onlyActive, string $keyColumnName = 'value')

Counterpart to values() which removes the item from the cache

static string
createCacheKey()

No description

static array
valuesByID(int $id, bool $flip = FALSE, bool $grouping = FALSE, bool $localize = FALSE, string $labelColumnName = 'label', bool $onlyActive = TRUE, bool $fresh = FALSE)

This function retrieves all the values for the specific option group by id.

static 
lookupValues(array $params, array $names, bool $flip = FALSE)

Lookup titles OR ids for a set of option_value populated fields. The retrieved value is assigned a new field name by id or id's by title (each within a specified option_group).

static null
getLabel(string $groupName, $value, bool $onlyActiveValue = TRUE) deprecated

No description

static null
getValue(string $groupName, $label, string $labelField = 'label', string $labelType = 'String', string $valueField = 'value') deprecated

No description

static string
getDefaultValue(string $groupName)

Get option_value.value from default option_value row for an option group

static int
createAssoc(string $groupName, array $values, int $defaultID, null $groupTitle = NULL)

Creates a new option group with the passed in values.

static 
getAssoc(string $groupName, $values, bool $flip = FALSE, string $field = 'name')

No description

static 
deleteAssoc(string $groupName, string $operator = "=")

No description

static array
getRowValues(string $groupName, $fieldValue, string $field = 'name', string $fieldType = 'String', bool $active = TRUE, bool $localize = FALSE)

No description

static 
flush(string $name, array $params = array())

Wrapper for calling values with fresh set to true to empty the given value.

static 
flushAll()

No description

Details

at line 55
static array valuesCommon(CRM_Core_DAO $dao, bool $flip = FALSE, bool $grouping = FALSE, bool $localize = FALSE, string $valueColumnName = 'label')

Parameters

CRM_Core_DAO $dao
bool $flip
bool $grouping
bool $localize
string $valueColumnName

Return Value

array

at line 117
static array values(string $name, bool $flip = FALSE, bool $grouping = FALSE, bool $localize = FALSE, string $condition = NULL, string $labelColumnName = 'label', bool $onlyActive = TRUE, bool $fresh = FALSE, string $keyColumnName = 'value', string $orderBy = 'weight')

This function retrieves all the values for the specific option group by name this is primarily used to create various html based form elements (radio, select, checkbox etc). OptionGroups for most cases have the 'label' in the label column and the 'id' or 'name' in the value column

Parameters

string $name name of the option group.
bool $flip results are return in id => label format if false. if true, the results are reversed
bool $grouping if true, return the value in 'grouping' column.
bool $localize if true, localize the results before returning.
string $condition add another condition to the sql query.
string $labelColumnName the column to use for 'label'.
bool $onlyActive return only the action option values.
bool $fresh ignore cache entries and go back to DB.
string $keyColumnName the column to use for 'key'.
string $orderBy the column to use for ordering.

Return Value

array The values as specified by the params

at line 193
static protected flushValues(string $name, $flip, $grouping, $localize, $condition, string $labelColumnName, $onlyActive, string $keyColumnName = 'value')

Counterpart to values() which removes the item from the cache

Parameters

string $name
$flip
$grouping
$localize
$condition
string $labelColumnName
$onlyActive
string $keyColumnName

at line 203
static protected string createCacheKey()

Return Value

string

at line 232
static array valuesByID(int $id, bool $flip = FALSE, bool $grouping = FALSE, bool $localize = FALSE, string $labelColumnName = 'label', bool $onlyActive = TRUE, bool $fresh = FALSE)

This function retrieves all the values for the specific option group by id.

this is primarily used to create various html based form elements (radio, select, checkbox etc). OptionGroups for most cases have the 'label' in the label column and the 'id' or 'name' in the value column

Parameters

int $id id of the option group.
bool $flip results are return in id => label format if false. if true, the results are reversed
bool $grouping if true, return the value in 'grouping' column.
bool $localize if true, localize the results before returning.
string $labelColumnName the column to use for 'label'.
bool $onlyActive
bool $fresh

Return Value

array Array of values as specified by the above params

at line 283
static lookupValues(array $params, array $names, bool $flip = FALSE)

Lookup titles OR ids for a set of option_value populated fields. The retrieved value is assigned a new field name by id or id's by title (each within a specified option_group).

Parameters

array $params Reference array of values submitted by the form. Based on. $flip, creates new elements in $params for each field in the $names array. If $flip = false, adds root field name => title If $flip = true, adds actual field name => id
array $names Array of field names we want transformed. Array key = 'postName' (field name submitted by form in $params). Array value = array('newName' => $newName, 'groupName' => $groupName).
bool $flip

at line 344
static null getLabel(string $groupName, $value, bool $onlyActiveValue = TRUE) deprecated

deprecated - use CRM_Core_Pseudoconstant::getLabel

Parameters

string $groupName
$value
bool $onlyActiveValue

Return Value

null

at line 388
static null getValue(string $groupName, $label, string $labelField = 'label', string $labelType = 'String', string $valueField = 'value') deprecated

deprecated This function is not cached.

Parameters

string $groupName
$label
string $labelField
string $labelType
string $valueField

Return Value

null

at line 435
static string getDefaultValue(string $groupName)

Get option_value.value from default option_value row for an option group

Parameters

string $groupName The name of the option group.

Return Value

string the value from the row where is_default = true

at line 483
static int createAssoc(string $groupName, array $values, int $defaultID, null $groupTitle = NULL)

Creates a new option group with the passed in values.

Parameters

string $groupName The name of the option group - make sure there is no conflict.
array $values The associative array that has information on the option values. the keys of this array are: string 'title' (required) string 'value' (required) string 'name' (optional) string 'description' (optional) int 'weight' (optional) - the order in which the value are displayed bool 'is_default' (optional) - is this the default one to display when rendered in form bool 'is_active' (optional) - should this element be rendered
int $defaultID (reference) - the option value ID of the default element (if set) is returned else 'null'.
null $groupTitle The optional label of the option group else set to group name.

Return Value

int the option group ID

at line 523
static getAssoc(string $groupName, $values, bool $flip = FALSE, string $field = 'name')

Parameters

string $groupName
$values
bool $flip
string $field

at line 567
static deleteAssoc(string $groupName, string $operator = "=")

Parameters

string $groupName
string $operator

at line 591
static array getRowValues(string $groupName, $fieldValue, string $field = 'name', string $fieldType = 'String', bool $active = TRUE, bool $localize = FALSE)

Parameters

string $groupName
$fieldValue
string $field
string $fieldType
bool $active
bool $localize if true, localize the results before returning.

Return Value

array

at line 647
static flush(string $name, array $params = array())

Wrapper for calling values with fresh set to true to empty the given value.

Since there appears to be some inconsistency (@todo remove inconsistency) around the pseudoconstant operations (for example CRM_Contribution_Pseudoconstant::paymentInstrument doesn't specify isActive which is part of the cache key will do a couple of variations & aspire to someone cleaning it up later

Parameters

string $name
array $params

at line 679
static flushAll()