public function OrderReport::buildFieldDefinitions in Commerce Reporting 8
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 BundlePluginInterface::buildFieldDefinitions
File
- src/
Plugin/ Commerce/ ReportType/ OrderReport.php, line 24
Class
- OrderReport
- Provides the basic Order Report.
Namespace
Drupal\commerce_reports\Plugin\Commerce\ReportTypeCode
public function buildFieldDefinitions() {
$fields = [];
$fields['order_type_id'] = BundleFieldDefinition::create('entity_reference')
->setLabel(t('Order type'))
->setDescription(t('The order type.'))
->setSetting('target_type', 'commerce_order_type')
->setReadOnly(TRUE);
$fields['amount'] = BundleFieldDefinition::create('commerce_price')
->setLabel(t('Total Amount'))
->setDescription(t('The total amount of the order'))
->setCardinality(1)
->setRequired(TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['mail'] = BundleFieldDefinition::create('email')
->setLabel(t('Contact email'))
->setDescription(t('The email address associated with the order.'))
->setCardinality(1)
->setSetting('max_length', 255)
->setRequired(TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['billing_address'] = BundleFieldDefinition::create('address')
->setLabel(t('Address'))
->setDescription(t('The store address.'))
->setCardinality(1)
->setRequired(TRUE)
->setDisplayConfigurable('view', TRUE);
return $fields;
}