function charts_cast_element_integer_values in Charts 8
Same name and namespace in other branches
- 7.2 charts.module \charts_cast_element_integer_values()
Recursive function to cast integer values.
Parameters
mixed $element: Cast options to integers to avoid redundant library fixing problems.
File
- includes/
charts.pages.inc, line 180 - Menu callbacks for Charts module.
Code
function charts_cast_element_integer_values(&$element) {
$integer_options = array(
// Chart options.
'#title_font_size',
'#font_size',
'#legend_title_font_size',
'#legend_font_size',
'#width',
'#height',
// Axis options.
'#title_font_size',
'#labels_font_size',
'#labels_rotation',
'#max',
'#min',
// Data options.
'#decimal_count',
);
foreach ($element as $property_name => $value) {
if (is_array($element[$property_name])) {
charts_cast_element_integer_values($element[$property_name]);
}
elseif ($property_name && in_array($property_name, $integer_options)) {
$element[$property_name] = is_null($element[$property_name]) || strlen($element[$property_name]) === 0 ? NULL : (int) $element[$property_name];
}
}
}