You are here

protected function PhysicalWidgetBase::getDefaultUnit in Physical Fields 8

Gets the default unit for the current field.

Return value

string The default unit.

4 calls to PhysicalWidgetBase::getDefaultUnit()
DimensionsDefaultWidget::formElement in src/Plugin/Field/FieldWidget/DimensionsDefaultWidget.php
Returns the form for a single field widget.
MeasurementDefaultWidget::formElement in src/Plugin/Field/FieldWidget/MeasurementDefaultWidget.php
Returns the form for a single field widget.
PhysicalWidgetBase::settingsForm in src/Plugin/Field/FieldWidget/PhysicalWidgetBase.php
Returns a form to configure settings for the widget.
PhysicalWidgetBase::settingsSummary in src/Plugin/Field/FieldWidget/PhysicalWidgetBase.php
Returns a short summary for the current widget settings.

File

src/Plugin/Field/FieldWidget/PhysicalWidgetBase.php, line 76

Class

PhysicalWidgetBase
Provides base functionality for physical widgets.

Namespace

Drupal\physical\Plugin\Field\FieldWidget

Code

protected function getDefaultUnit() {
  $default_unit = $this
    ->getSetting('default_unit');
  if (!$default_unit) {

    /** @var \Drupal\physical\UnitInterface $unit_class */
    $unit_class = $this
      ->getUnitClass();
    $default_unit = $unit_class::getBaseUnit();
  }
  return $default_unit;
}