public function Dimension::calculate in Dimension 2.0.x
Same name and namespace in other branches
- 8 src/Plugin/Field/FieldType/Dimension.php \Drupal\dimension\Plugin\Field\FieldType\Dimension::calculate()
- 2.1.x src/Plugin/Field/FieldType/Dimension.php \Drupal\dimension\Plugin\Field\FieldType\Dimension::calculate()
1 call to Dimension::calculate()
- Dimension::preSave in src/
Plugin/ Field/ FieldType/ Dimension.php - Defines custom presave behavior for field values.
File
- src/
Plugin/ Field/ FieldType/ Dimension.php, line 282
Class
Namespace
Drupal\dimension\Plugin\Field\FieldTypeCode
public function calculate($values) {
$value = 1;
/** @noinspection StaticInvocationViaThisInspection */
foreach ($this
->fields() as $key => $label) {
$settings = $this
->getSetting($key);
$values[$key] = round($values[$key], $this
->getSetting($key . '_scale'));
$value *= $values[$key] * $settings['factor'];
}
return round($value, $this
->getSetting('value_scale'));
}