public static function PartyPrimaryFields::executeCallback in Party 7
Execute a callback on a value.
1 call to PartyPrimaryFields::executeCallback()
- PartyController::setPrimaryFields in includes/
party.entity.inc - Set the primary fields for the party.
File
- includes/
party.primary_fields.inc, line 386 - Primary field related functions and callbacks.
Class
- PartyPrimaryFields
- Helper class for primary fields.
Code
public static function executeCallback($value, $source, $target) {
// Check we want to execute callback.
if (isset($source['callback'])) {
// Get our source info and check the callback exists.
$source_info = self::getSource($source);
if (isset($source_info['callbacks'][$source['callback']])) {
// Get the callback info.
$callback = $source_info['callbacks'][$source['callback']];
// Load an include if necessary.
if (isset($callback['file'])) {
if (is_array($callback['file'])) {
module_load_include($callback['file']['type'], $callback['file']['module'], $callback['file']['name']);
}
else {
require_once DRUPAL_ROOT . '/' . $callback['file'];
}
}
// If the callback is valid, execute it.
if (is_callable($callback['callback'])) {
$target_info = self::getPropertyInfo('party', 'party', $target);
$value = call_user_func($callback['callback'], $value, $target, $target_info, $source_info);
}
}
}
return $value;
}