function FieldStorageConfig::postCreate

Same name in other branches
  1. 10 core/modules/field/src/Entity/FieldStorageConfig.php \Drupal\field\Entity\FieldStorageConfig::postCreate()

Overrides EntityBase::postCreate

File

core/modules/field/src/Entity/FieldStorageConfig.php, line 290

Class

FieldStorageConfig
Defines the Field storage configuration entity.

Namespace

Drupal\field\Entity

Code

public function postCreate(EntityStorageInterface $storage) {
    parent::postCreate($storage);
    // Check that the field type is known.
    $field_type = \Drupal::service('plugin.manager.field.field_type')->getDefinition($this->type, FALSE);
    if (!$field_type) {
        throw new FieldException("Attempt to create a field storage of unknown type {$this->type}.");
    }
    $this->module = $field_type['provider'];
    // Make sure all expected runtime settings are present.
    $default_settings = \Drupal::service('plugin.manager.field.field_type')->getDefaultStorageSettings($this->getType());
    // Filter out any unknown (unsupported) settings.
    $supported_settings = array_intersect_key($this->getSettings(), $default_settings);
    $this->set('settings', $supported_settings + $default_settings);
}

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