public static function BaseFieldDefinition::create in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Field/BaseFieldDefinition.php \Drupal\Core\Field\BaseFieldDefinition::create()
Creates a new field definition.
Parameters
string $type: The type of the field.
Return value
static A new field definition object.
Overrides ListDataDefinition::create
25 calls to BaseFieldDefinition::create()
- BaseFieldDefinition::createFromItemType in core/
lib/ Drupal/ Core/ Field/ BaseFieldDefinition.php - Creates a new list data definition for items of the given data type.
- BaseFieldDefinitionTest::testCustomStorage in core/
tests/ Drupal/ Tests/ Core/ Entity/ BaseFieldDefinitionTest.php - Tests custom storage.
- BaseFieldDefinitionTest::testDefaultFieldSettings in core/
tests/ Drupal/ Tests/ Core/ Entity/ BaseFieldDefinitionTest.php - Tests the initialization of default field settings.
- BaseFieldDefinitionTest::testDefaultValueCallback in core/
tests/ Drupal/ Tests/ Core/ Entity/ BaseFieldDefinitionTest.php - Tests default value callbacks.
- BaseFieldDefinitionTest::testFieldCardinality in core/
tests/ Drupal/ Tests/ Core/ Entity/ BaseFieldDefinitionTest.php - Tests field cardinality.
File
- core/
lib/ Drupal/ Core/ Field/ BaseFieldDefinition.php, line 61 - Contains \Drupal\Core\Field\BaseFieldDefinition.
Class
- BaseFieldDefinition
- A class for defining entity fields.
Namespace
Drupal\Core\FieldCode
public static function create($type) {
$field_definition = new static(array());
$field_definition->type = $type;
$field_definition->itemDefinition = FieldItemDataDefinition::create($field_definition);
// Create a definition for the items, and initialize it with the default
// settings for the field type.
// @todo Cleanup in https://www.drupal.org/node/2116341.
$field_type_manager = \Drupal::service('plugin.manager.field.field_type');
$default_settings = $field_type_manager
->getDefaultStorageSettings($type) + $field_type_manager
->getDefaultFieldSettings($type);
$field_definition->itemDefinition
->setSettings($default_settings);
return $field_definition;
}