function _access_field_allowed_values in Access Control Kit 7
Allowed values callback for realm fields.
This function is named in $field['settings']['allowed_values_function'] on scheme realm fields. It is called by list_allowed_values() to generate the options for the list field.
The strings are not safe for output. Keys and values of the array should be sanitized through field_filter_xss() before being displayed.
Parameters
array $field: The field definition.
array|null $instance: A field instance array. May be NULL.
array|null $entity_type: The type of entity; for example, 'node' or 'user'. May be NULL.
object|null $entity: The entity object. May be NULL.
true &$cacheable: Boolean passed by reference to indicate whether the value list returned by this function should be cached by list_allowed_values(). Passed in as TRUE; if set to FALSE, the allowed values list will not be statically cached.
Return value
array The array of allowed values. Keys of the array are the raw stored values (number or text), values of the array are the display labels.
4 string references to '_access_field_allowed_values'
- access_access_scheme_info in ./
access.access.inc - Implements hook_access_scheme_info().
- access_access_scheme_presave in ./
access.access.inc - Implements hook_access_scheme_presave().
- access_scheme_list_field_settings in callbacks/
access.list.inc - Settings callback for the list field scheme types.
- access_update_7105 in ./
access.install - Convert access control kit fields to standard list fields.
File
- ./
access.module, line 565 - The access control kit module.
Code
function _access_field_allowed_values($field, $instance, $entity_type, $entity, &$cacheable) {
$values = array();
if (!empty($field['bundles']['access_grant'])) {
// A realm field should only be attached to one scheme, so we can just take
// the first value in the bundle list.
$machine_name = reset($field['bundles']['access_grant']);
$scheme = access_scheme_machine_name_load($machine_name);
if ($scheme) {
$values = $scheme->realms;
}
}
return $values;
}