You are here

public function PurchasableEntityDangerousGoods::buildFieldDefinitions in Commerce FedEx 8

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

modules/dangerous/src/Plugin/Commerce/EntityTrait/PurchasableEntityDangerousGoods.php, line 24

Class

PurchasableEntityDangerousGoods
Provides the "fedex_dangerous" trait.

Namespace

Drupal\commerce_fedex_dangerous\Plugin\Commerce\EntityTrait

Code

public function buildFieldDefinitions() {
  $id = $this
    ->getPluginId();
  $fields[$id . '_accessibility'] = BundleFieldDefinition::create('list_string')
    ->setLabel($this
    ->t('Require Dangerous Goods/Hazardous Materials Shipping'))
    ->setCardinality(1)
    ->setSetting('allowed_values', [
    0 => "None",
  ] + FedEx::enumToList(DangerousGoodsAccessibilityType::getValidValues()))
    ->setDisplayOptions('form', [
    'type' => 'options_select',
    'weight' => 95,
  ]);
  return $fields;
}