public function Role::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
- src/
Plugin/ Commerce/ LicenseType/ Role.php, line 170
Class
- Role
- Provides a license type which grants one or more roles.
Namespace
Drupal\commerce_license\Plugin\Commerce\LicenseTypeCode
public function buildFieldDefinitions() {
$fields = parent::buildFieldDefinitions();
$fields['license_role'] = BundleFieldDefinition::create('entity_reference')
->setLabel(t('Role'))
->setDescription(t('The role this product grants access to.'))
->setCardinality(1)
->setRequired(TRUE)
->setSetting('target_type', 'user_role')
->setDisplayOptions('form', [
'type' => 'options_select',
])
->setDisplayOptions('view', [
'label' => 'inline',
'type' => 'entity_reference_label',
'weight' => 1,
'settings' => [
'link' => TRUE,
],
]);
return $fields;
}