public static function Chart::castElementIntergerValues in Charts 8.4
Same name and namespace in other branches
- 5.0.x src/Element/Chart.php \Drupal\charts\Element\Chart::castElementIntergerValues()
Casts recursively integer values.
Parameters
array $element: The element.
1 call to Chart::castElementIntergerValues()
- Chart::preRender in src/
Element/ Chart.php - Main #pre_render callback to expand a chart element.
File
- src/
Element/ Chart.php, line 226
Class
- Chart
- Provides a chart render element.
Namespace
Drupal\charts\ElementCode
public static function castElementIntergerValues(array &$element) {
// Cast options to integers to avoid redundant library fixing problems.
$integer_options = [
// 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])) {
self::castElementIntergerValues($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];
}
}
}