You are here

function tablefield_post_update_implement_tablefield_field_config_schema in TableField 8.2

Resave field config to apply the tablefield schema changes.

File

./tablefield.post_update.php, line 15
Post update functions for tablefield.

Code

function tablefield_post_update_implement_tablefield_field_config_schema(&$sandbox = NULL) {
  \Drupal::classResolver(ConfigEntityUpdater::class)
    ->update($sandbox, 'field_config', function (FieldConfigInterface $fieldConfig) {
    if ($fieldConfig
      ->getFieldStorageDefinition()
      ->getType() !== 'tablefield') {
      return FALSE;
    }
    $settings = $fieldConfig
      ->getSettings();
    $settings['export'] = (bool) $settings['export'];
    $settings['restrict_rebuild'] = (bool) $settings['restrict_rebuild'];
    $settings['restrict_import'] = (bool) $settings['restrict_import'];
    $settings['lock_values'] = (bool) $settings['lock_values'];
    $settings['cell_processing'] = (int) $settings['cell_processing'];
    $settings['empty_rules']['ignore_table_structure'] = (bool) $settings['empty_rules']['ignore_table_structure'];
    $settings['empty_rules']['ignore_table_header'] = (bool) $settings['empty_rules']['ignore_table_header'];
    $fieldConfig
      ->set('settings', $settings);
    return TRUE;
  });
}