function rules_pack_variables in Rules 6
Packs the given variables ready for serialization. Data types which are identifiable are replaced by their identifiers and loaded fresh from the db when the variables are unpacked.
Parameters
$variables: An array of variable information
$data: An array of data for the given variables, in the same order as the information.
Return value
The packed variables or FALSE if packing failed.
1 call to rules_pack_variables()
- rules_scheduler_schedule_task in rules_scheduler/
rules_scheduler.module - Schedule a task by inserting it into the database.
File
- rules/
rules.variables.inc, line 223 - Provides functions and classes for handling variables
Code
function rules_pack_variables($variables, $data) {
$packed = array(
'variables' => $variables,
'data' => array(),
);
foreach (array_values($variables) as $i => $info) {
$type = rules_get_data_object($info, $data[$i]);
if (isset($type) && $type
->is_identifiable()) {
$id = $type
->get_identifier();
if (!isset($id)) {
return FALSE;
}
$packed['data'][$i] = $id;
}
else {
$packed['data'][$i] = $data[$i];
}
}
return $packed;
}