Documentation

CRM_Core_OptionGroup
in package

Tags
copyright

CiviCRM LLC https://civicrm.org/licensing

Table of Contents

Properties

$_cache  : mixed
$_domainIDGroups  : array<string|int, mixed>
Deprecated flag for domain-specific optionValues. The `is_domain` column is no longer used.
$_values  : mixed

Methods

createAssoc()  : int
Creates a new option group with the passed in values.
deleteAssoc()  : mixed
flush()  : mixed
Wrapper for calling values with fresh set to true to empty the given value.
flushAll()  : mixed
Flush all the places where option values are cached.
getAssoc()  : mixed
getDefaultValue()  : string
Get option_value.value from default option_value row for an option group
getRowValues()  : array<string|int, mixed>
isDomainOptionGroup()  : bool
lookupValues()  : mixed
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).
values()  : array<string|int, mixed>
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
valuesByID()  : array<string|int, mixed>
This function retrieves all the values for the specific option group by id.
valuesCommon()  : array<string|int, mixed>
createCacheKey()  : string
flushValues()  : mixed
Counterpart to values() which removes the item from the cache
getLegacyFromEmailAddressValues()  : array<string|int, mixed>
Uses api adapter to fetch `from_email_address` options as if it were still an option group

Properties

$_domainIDGroups

Deprecated flag for domain-specific optionValues. The `is_domain` column is no longer used.

public static array<string|int, mixed> $_domainIDGroups = []

Any set of options that needs domain specificity should be stored in its own table.

Methods

createAssoc()

Creates a new option group with the passed in values.

public static createAssoc(string $groupName, array<string|int, mixed> &$values, int &$defaultID[, null $groupTitle = null ]) : int
Parameters
$groupName : string

The name of the option group - make sure there is no conflict.

$values : array<string|int, mixed>

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

$defaultID : int

(reference) - the option value ID of the default element (if set) is returned else 'null'.

$groupTitle : null = null

The optional label of the option group else set to group name.

Return values
int

the option group ID

deleteAssoc()

public static deleteAssoc(string $groupName[, string $operator = "=" ]) : mixed
Parameters
$groupName : string
$operator : string = "="

flush()

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

public static flush(string $name[, array<string|int, mixed> $params = [] ]) : mixed

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
$name : string
$params : array<string|int, mixed> = []

flushAll()

Flush all the places where option values are cached.

public static flushAll() : mixed

Note that this is called from CRM_Core_PseudoConstant::flush() so we should resist the intuitive urge to flush that class.

getAssoc()

public static getAssoc(string $groupName, mixed &$values[, bool $flip = false ][, string $field = 'name' ]) : mixed
Parameters
$groupName : string
$values : mixed
$flip : bool = false
$field : string = 'name'

getDefaultValue()

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

public static getDefaultValue(string $groupName) : string
Parameters
$groupName : string

The name of the option group.

Return values
string

the value from the row where is_default = true

getRowValues()

public static getRowValues(string $groupName, mixed $fieldValue[, string $field = 'name' ][, string $fieldType = 'String' ][, bool $active = true ][, bool $localize = false ]) : array<string|int, mixed>
Parameters
$groupName : string
$fieldValue : mixed
$field : string = 'name'
$fieldType : string = 'String'
$active : bool = true
$localize : bool = false

if true, localize the results before returning.

Return values
array<string|int, mixed>

isDomainOptionGroup()

public static isDomainOptionGroup(mixed $groupName) : bool
  • going forward the optionValue table will not support domain-specific options
Parameters
$groupName : mixed
Return values
bool

lookupValues()

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).

public static lookupValues(array<string|int, mixed> &$params, array<string|int, mixed> $names[, bool $flip = false ]) : mixed
Parameters
$params : array<string|int, mixed>

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

$names : array<string|int, mixed>

Array of field names we want transformed. Array key = 'postName' (field name submitted by form in $params). Array value = array('newName' => $newName, 'groupName' => $groupName).

$flip : bool = false

values()

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

public static & 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' ]) : array<string|int, mixed>
Parameters
$name : string

name of the option group.

$flip : bool = false

results are return in id => label format if false. if true, the results are reversed

$grouping : bool = false

if true, return the value in 'grouping' column.

$localize : bool = false

if true, localize the results before returning.

$condition : string = null

add another condition to the sql query.

$labelColumnName : string = 'label'

the column to use for 'label'.

$onlyActive : bool = true

return only the action option values.

$fresh : bool = false

ignore cache entries and go back to DB.

$keyColumnName : string = 'value'

the column to use for 'key'.

$orderBy : string = 'weight'

the column to use for ordering.

Return values
array<string|int, mixed>

The values as specified by the params

valuesByID()

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

public static & valuesByID(int $id[, bool $flip = false ][, bool $grouping = false ][, bool $localize = false ][, string $labelColumnName = 'label' ][, bool $onlyActive = true ][, bool $fresh = false ]) : array<string|int, mixed>

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
$id : int

id of the option group.

$flip : bool = false

results are return in id => label format if false. if true, the results are reversed

$grouping : bool = false

if true, return the value in 'grouping' column.

$localize : bool = false

if true, localize the results before returning.

$labelColumnName : string = 'label'

the column to use for 'label'.

$onlyActive : bool = true
$fresh : bool = false
Tags
void
Return values
array<string|int, mixed>

Array of values as specified by the above params

valuesCommon()

public static & valuesCommon(CRM_Core_DAO $dao[, bool $flip = false ][, bool $grouping = false ][, bool $localize = false ][, string $valueColumnName = 'label' ]) : array<string|int, mixed>
Parameters
$dao : CRM_Core_DAO
$flip : bool = false
$grouping : bool = false
$localize : bool = false
$valueColumnName : string = 'label'
Return values
array<string|int, mixed>

createCacheKey()

protected static createCacheKey(mixed $id) : string
Parameters
$id : mixed
Return values
string

flushValues()

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

protected static flushValues(string $name, mixed $flip, mixed $grouping, mixed $localize, mixed $condition, string $labelColumnName, mixed $onlyActive[, string $keyColumnName = 'value' ]) : mixed
Parameters
$name : string
$flip : mixed
$grouping : mixed
$localize : mixed
$condition : mixed
$labelColumnName : string
$onlyActive : mixed
$keyColumnName : string = 'value'

getLegacyFromEmailAddressValues()

Uses api adapter to fetch `from_email_address` options as if it were still an option group

private static getLegacyFromEmailAddressValues(bool $onlyActive, mixed $condition, string $labelColumnName, string $keyColumnName) : array<string|int, mixed>
Parameters
$onlyActive : bool
$condition : mixed
$labelColumnName : string
$keyColumnName : string
Tags
see
SiteEmailLegacyOptionValueAdapter
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

        
On this page

Search results