Module Description
Provides an API for storing and manipulating physical measurements.
Supports unit conversions.
Drupal 8
Supported measurement types:
* Area
* Length
* Temperature
* Volume
* Weight
Provided field types:
* Physical measurement: Stores a single measurement and its unit.
* Physical dimensions: Stores the length/width/height measurements and their unit.
Other features:
* Language-specific number input and formatting
* Value objects with support for bcmath-based arithmetic.
Example:
use Drupal\physical\Weight; use Drupal\physical\WeightUnit; $weight = new Weight('100', WeightUnit::KILOGRAM); $other_weight = new Weight('120', WeightUnit::KILOGRAM); // Add the two weights together then express them in pounds. $new_weight = $weight->add($other_weight)->convert(WeightUnit::POUND); Incompatibility notes Physical 1.3+ is incompatible with Commerce versions prior to 2.34 (See https://www.drupal.org/project/physical/issues/3345698#comment-15019339).
Drupal 7
Provided field types:
* Physical volume: Stores a volume value with its unit of measurement.
* Physical weight: Stores a weight value with its unit of measurement.
* Physical dimensions: Stores values for length, width, and height with their unit of measurement.
All three field types support locking the unit of measurement on the entity add/edit form.
Supports unit conversions.
Drupal 8
Supported measurement types:
* Area
* Length
* Temperature
* Volume
* Weight
Provided field types:
* Physical measurement: Stores a single measurement and its unit.
* Physical dimensions: Stores the length/width/height measurements and their unit.
Other features:
* Language-specific number input and formatting
* Value objects with support for bcmath-based arithmetic.
Example:
use Drupal\physical\Weight; use Drupal\physical\WeightUnit; $weight = new Weight('100', WeightUnit::KILOGRAM); $other_weight = new Weight('120', WeightUnit::KILOGRAM); // Add the two weights together then express them in pounds. $new_weight = $weight->add($other_weight)->convert(WeightUnit::POUND); Incompatibility notes Physical 1.3+ is incompatible with Commerce versions prior to 2.34 (See https://www.drupal.org/project/physical/issues/3345698#comment-15019339).
Drupal 7
Provided field types:
* Physical volume: Stores a volume value with its unit of measurement.
* Physical weight: Stores a weight value with its unit of measurement.
* Physical dimensions: Stores values for length, width, and height with their unit of measurement.
All three field types support locking the unit of measurement on the entity add/edit form.
Module Link
Project Usage
11549
Security Covered
Covered By Security Advisory
Version Available
Production
Module Summary
This module provides an API for storing and manipulating physical measurements, supporting unit conversions for area, length, temperature, volume, and weight, with field types for single measurements, dimensions, and language-specific number input, along with value objects for arithmetic operations.
Data Name
physical