function variable_build_variable in Variable 6
Same name and namespace in other branches
- 7.2 variable.inc \variable_build_variable()
- 7 variable.inc \variable_build_variable()
Build single variable
Some variables may spawn into multiple ones
1 call to variable_build_variable()
- variable_build_info in ./
variable.inc - Build variable information, which is cached by language
File
- ./
variable.inc, line 45 - Variable API module. Extended API.
Code
function variable_build_variable($name, $variable, $options, $defaults = array()) {
// Set global defaults and type defaults for each variable
$variable += $defaults;
$variable += array(
'group' => 'others',
'name' => $name,
'description' => '',
);
$variable += variable_type_defaults($variable['type']);
// Add group information
if (($group_info = variable_group($variable['group'])) && isset($group_info['access'])) {
$variable += array(
'access' => $group_info['access'],
);
}
if (isset($variable['build_callback'])) {
$variable_build = call_user_func($variable['build_callback'], $variable, $options);
}
else {
$variable_build = array(
$name => $variable,
);
}
// If the variable has children, we have to build each of them too
if (isset($variable_build[$name]) && ($children = array_diff(array_keys($variable_build), array(
$name,
)))) {
$variable_build[$name] += array(
'children' => $children,
);
$defaults['group'] = $variable['group'];
$defaults['parent'] = $name;
foreach ($children as $key) {
$variable_build = array_merge($variable_build, variable_build_variable($key, $variable_build[$key], $options, $defaults));
}
}
return $variable_build;
}