You are here

public function LicenseSubscription::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 SubscriptionTypeBase::buildFieldDefinitions

File

src/Plugin/Commerce/SubscriptionType/LicenseSubscription.php, line 118

Class

LicenseSubscription
Provides a Commerce Recurring subscription type for use with licenses.

Namespace

Drupal\commerce_license\Plugin\Commerce\SubscriptionType

Code

public function buildFieldDefinitions() {
  $fields = parent::buildFieldDefinitions();
  $fields['license'] = BundleFieldDefinition::create('entity_reference')
    ->setLabel(t('License'))
    ->setDescription(t('The license this subscription controls.'))
    ->setCardinality(1)
    ->setRequired(TRUE)
    ->setSetting('target_type', 'commerce_license');
  return $fields;
}