function _entity_translation_element_add_callback in Entity Translation 7
Adds a callback function to the given FAPI element.
Drupal core only adds default element callbacks if the respective handler type is not defined yet. This function ensures that our callback is only prepended/appended to the default set of callbacks instead of replacing it.
Parameters
$element: The FAPI element.
$type: The callback type, e.g. '#pre_render' or '#process'.
$function: The name of the callback to add.
$prepend: Set to TRUE to add the new callback to the beginning of the existing set of callbacks, and set it to FALSE to append it at the end.
1 call to _entity_translation_element_add_callback()
- EntityTranslationDefaultHandler::entityFormSharedElements in includes/
translation.handler.inc - Either remove access or add a translatability clue depending on the current user's "edit translation shared fields" permissions.
File
- ./
entity_translation.module, line 1448
Code
function _entity_translation_element_add_callback(&$element, $type, $function, $prepend = TRUE) {
// If handler type has not been set, add defaults from element_info().
if (!isset($element[$type])) {
$element_type = isset($element['#type']) ? $element['#type'] : 'markup';
$element_info = element_info($element_type);
$element[$type] = isset($element_info[$type]) ? $element_info[$type] : array();
}
if ($prepend) {
array_unshift($element[$type], $function);
}
else {
$element[$type][] = $function;
}
}