function FieldConfigBase::postCreate

Same name in other branches
  1. 9 core/lib/Drupal/Core/Field/FieldConfigBase.php \Drupal\Core\Field\FieldConfigBase::postCreate()
  2. 8.9.x core/lib/Drupal/Core/Field/FieldConfigBase.php \Drupal\Core\Field\FieldConfigBase::postCreate()
  3. 11.x core/lib/Drupal/Core/Field/FieldConfigBase.php \Drupal\Core\Field\FieldConfigBase::postCreate()

Overrides EntityBase::postCreate

1 call to FieldConfigBase::postCreate()
FieldConfig::postCreate in core/modules/field/src/Entity/FieldConfig.php
Acts on a created entity before hooks are invoked.
1 method overrides FieldConfigBase::postCreate()
FieldConfig::postCreate in core/modules/field/src/Entity/FieldConfig.php
Acts on a created entity before hooks are invoked.

File

core/lib/Drupal/Core/Field/FieldConfigBase.php, line 276

Class

FieldConfigBase
Base class for configurable field definitions.

Namespace

Drupal\Core\Field

Code

public function postCreate(EntityStorageInterface $storage) {
    parent::postCreate($storage);
    // If it was not present in the $values passed to create(), (e.g. for
    // programmatic creation), populate the denormalized field_type property
    // from the field storage, so that it gets saved in the config record.
    if (empty($this->field_type)) {
        $this->field_type = $this->getFieldStorageDefinition()
            ->getType();
    }
    // Make sure all expected runtime settings are present.
    $default_settings = \Drupal::service('plugin.manager.field.field_type')->getDefaultFieldSettings($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.