public function ProductVariationCommerceFile::buildFieldDefinitions in Commerce File 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
- src/
Plugin/ Commerce/ EntityTrait/ ProductVariationCommerceFile.php, line 27
Class
- ProductVariationCommerceFile
- Provides an entity trait for Commerce Product Variation entities.
Namespace
Drupal\commerce_file\Plugin\Commerce\EntityTraitCode
public function buildFieldDefinitions() {
// Builds the field definitions.
$fields = [];
$fields['commerce_file'] = BundleFieldDefinition::create('file')
->setLabel($this
->t('File(s)'))
->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
->setRequired(TRUE)
->setSettings([
'file_extensions' => 'mp4 m4v flv wmv mp3 wav jpg jpeg png pdf doc docx ppt pptx xls xlsx',
'description_field' => 1,
'uri_scheme' => 'private',
])
->setDisplayOptions('form', [
'type' => 'file_generic',
]);
return $fields;
}