function entityreference_get_behavior_handlers in Entity reference 7
Get the behavior handlers for a given entityreference field.
14 calls to entityreference_get_behavior_handlers()
- entityreference_entity_crud in ./
entityreference.module - Invoke a behavior based on entity CRUD.
- entityreference_field_attach_delete in ./
entityreference.module - Implements hook_field_attach_delete().
- entityreference_field_attach_insert in ./
entityreference.module - Implements hook_field_attach_insert().
- entityreference_field_attach_update in ./
entityreference.module - Implements hook_field_attach_update().
- entityreference_field_delete in ./
entityreference.module - Implements hook_field_delete().
File
- ./
entityreference.module, line 153 - Entityreference primary module file.
Code
function entityreference_get_behavior_handlers($field, $instance = NULL) {
$object_cache = drupal_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];
}