You are here

public function MeasurementItem::toMeasurement in Physical Fields 8

Gets the Measurement value object for the current field item.

Return value

\Drupal\physical\Measurement A subclass of Measurement (Length, Volume, etc).

File

src/Plugin/Field/FieldType/MeasurementItem.php, line 158

Class

MeasurementItem
Plugin implementation of the 'physical_measurement' field type.

Namespace

Drupal\physical\Plugin\Field\FieldType

Code

public function toMeasurement() {
  $class = MeasurementType::getClass($this
    ->getSetting('measurement_type'));
  return new $class($this->number, $this->unit);
}