You are here

public function First::buildFieldDefinitions in Entity API 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

tests/modules/entity_module_bundle_plugin_test/src/Plugin/BundlePluginTest/First.php, line 22

Class

First
Provides the first bundle plugin.

Namespace

Drupal\entity_module_bundle_plugin_test\Plugin\BundlePluginTest

Code

public function buildFieldDefinitions() {
  $fields = [];
  $fields['first_mail'] = BundleFieldDefinition::create('email')
    ->setLabel(t('Email'))
    ->setRequired(TRUE);
  return $fields;
}