public function Dimension::calculate in Dimension 8
Same name and namespace in other branches
- 2.1.x src/Plugin/Field/FieldType/Dimension.php \Drupal\dimension\Plugin\Field\FieldType\Dimension::calculate()
- 2.0.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 291
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);
$storage_settings = $this
->getSetting('storage_' . $key);
$values[$key] = round($values[$key], $storage_settings['scale']);
$value *= $values[$key] * $settings['factor'];
}
$storage_settings = $this
->getSetting('storage_value');
return round($value, $storage_settings['scale']);
}