public function PurchasableEntitySubscriptionTrait::buildFieldDefinitions in Commerce Recurring Framework 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
- src/
Plugin/ Commerce/ EntityTrait/ PurchasableEntitySubscriptionTrait.php, line 22
Class
- PurchasableEntitySubscriptionTrait
- Provides a trait to enable purchasing of subscriptions.
Namespace
Drupal\commerce_recurring\Plugin\Commerce\EntityTraitCode
public function buildFieldDefinitions() {
$fields = [];
$fields['billing_schedule'] = BundleFieldDefinition::create('entity_reference')
->setLabel(t('Billing schedule'))
->setRequired(TRUE)
->setSetting('target_type', 'commerce_billing_schedule')
->setDisplayOptions('form', [
'type' => 'options_select',
])
->setDisplayConfigurable('form', TRUE);
$fields['subscription_type'] = BundleFieldDefinition::create('commerce_plugin_item:commerce_subscription_type')
->setLabel(t('Subscription type'))
->setRequired(TRUE)
->setDisplayOptions('form', [
'type' => 'commerce_plugin_select',
'weight' => 0,
])
->setDisplayConfigurable('form', TRUE);
return $fields;
}