You are here

public function LicenseWithField::buildFieldDefinitions in Commerce License 8.2

Builds the field definitions for entities of this bundle.

Important: Field names must be unique across all bundles. It is recommended to prefix them with the bundle name (plugin ID).

Return value

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

Overrides LicenseTypeBase::buildFieldDefinitions

File

tests/modules/commerce_license_test/src/Plugin/Commerce/LicenseType/LicenseWithField.php, line 37

Class

LicenseWithField
License type for testing a field can be set when granting and revoking.

Namespace

Drupal\commerce_license_test\Plugin\Commerce\LicenseType

Code

public function buildFieldDefinitions() {
  $fields = parent::buildFieldDefinitions();
  $fields['test_field'] = BundleFieldDefinition::create('text')
    ->setLabel(t('Test field'))
    ->setDescription(t('A test field that this plugin will set values on.'))
    ->setCardinality(1);
  return $fields;
}