public function FieldDefinition::setFieldStorageDefinition in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Field/FieldDefinition.php \Drupal\Core\Field\FieldDefinition::setFieldStorageDefinition()
Set the field storage definition.
Parameters
\Drupal\Core\Field\FieldStorageDefinitionInterface $storageDefinition: The field storage definition associated with this field definition.
Return value
$this
File
- core/
lib/ Drupal/ Core/ Field/ FieldDefinition.php, line 251
Class
- FieldDefinition
- A class for defining entity field definitions.
Namespace
Drupal\Core\FieldCode
public function setFieldStorageDefinition(FieldStorageDefinitionInterface $storageDefinition) {
$this->fieldStorageDefinition = $storageDefinition;
$this->itemDefinition = FieldItemDataDefinition::create($this);
// Create a definition for the items, and initialize it with the default
// settings for the field type.
$field_type_manager = \Drupal::service('plugin.manager.field.field_type');
$default_settings = $field_type_manager
->getDefaultFieldSettings($storageDefinition
->getType());
$this->itemDefinition
->setSettings($default_settings);
return $this;
}