You are here

public function PurchasableEntityShippable::buildFieldDefinitions in Commerce Shipping 8.2

Builds the field definitions.

THe provided field definitions will be created as configurable fields when the entity trait is installed for an entity type/bundle.

Return value

\Drupal\entity\BundleFieldDefinition[] An array of field definitions, keyed by field name.

Overrides EntityTraitBase::buildFieldDefinitions

File

src/Plugin/Commerce/EntityTrait/PurchasableEntityShippable.php, line 23

Class

PurchasableEntityShippable
Provides the "purchasable_entity_shippable" trait.

Namespace

Drupal\commerce_shipping\Plugin\Commerce\EntityTrait

Code

public function buildFieldDefinitions() {
  $fields = [];
  $fields['weight'] = BundleFieldDefinition::create('physical_measurement')
    ->setLabel('Weight')
    ->setRequired(TRUE)
    ->setSetting('measurement_type', MeasurementType::WEIGHT)
    ->setDisplayOptions('form', [
    'type' => 'physical_measurement_default',
    'weight' => 91,
  ]);
  return $fields;
}