1 entityreference.module | entityreference_get_behavior_handlers($field, $instance = NULL) |
Get the behavior handlers for a given entityreference field.
File
- core/
modules/ entityreference/ entityreference.module, line 108 - Entityreference primary module file.
Code
function entityreference_get_behavior_handlers($field, $instance = NULL) {
$object_cache = backdrop_static(__FUNCTION__);
$identifier = $field['field_name'];
if (!empty($instance)) {
$identifier .= ':' . $instance['entity_type'] . ':' . $instance['bundle'];
}
if (!isset($object_cache[$identifier])) {
$object_cache[$identifier] = array();
// Merge in defaults.
$field['settings'] += array('behaviors' => array());
$object_cache[$field['field_name']] = array();
$behaviors = !empty($field['settings']['handler_settings']['behaviors']) ? $field['settings']['handler_settings']['behaviors'] : array();
if (!empty($instance['settings']['behaviors'])) {
$behaviors = array_merge($behaviors, $instance['settings']['behaviors']);
}
foreach ($behaviors as $behavior => $settings) {
if (empty($settings['status'])) {
// Behavior is not enabled.
continue;
}
$object_cache[$identifier][] = _entityreference_get_behavior_handler($behavior);
}
}
return $object_cache[$identifier];
}