function FieldDefinition::setFieldStorageDefinition

Same name in other branches
  1. 9 core/lib/Drupal/Core/Field/FieldDefinition.php \Drupal\Core\Field\FieldDefinition::setFieldStorageDefinition()
  2. 8.9.x core/lib/Drupal/Core/Field/FieldDefinition.php \Drupal\Core\Field\FieldDefinition::setFieldStorageDefinition()
  3. 10 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\Field

Code

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.