You are here

public function Second::buildFieldDefinitions in Commerce Core 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

tests/modules/commerce_test/src/Plugin/Commerce/EntityTrait/Second.php, line 22

Class

Second
Provides the second entity trait.

Namespace

Drupal\commerce_test\Plugin\Commerce\EntityTrait

Code

public function buildFieldDefinitions() {
  $fields = [];

  // Intentionally conflicts with the field in the first trait.
  $fields['phone'] = BundleFieldDefinition::create('telephone')
    ->setLabel(t('Phone'))
    ->setRequired(TRUE);
  return $fields;
}