function system_post_update_convert_empty_description_entity_form_modes_to_null

Same name and namespace in other branches
  1. main core/modules/system/system.post_update.php \system_post_update_convert_empty_description_entity_form_modes_to_null()

Updates entity_form_mode descriptions from empty string to null.

File

core/modules/system/system.post_update.php, line 115

Code

function system_post_update_convert_empty_description_entity_form_modes_to_null(array &$sandbox) : void {
  \Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'entity_form_mode', function (EntityFormModeInterface $form_mode) : bool {
    // Entity form mode's `description` field must be stored as NULL at the
    // config level if they are empty.
    if ($form_mode->get('description') !== NULL && trim($form_mode->get('description')) === '') {
      $form_mode->set('description', NULL);
      return TRUE;
    }
    return FALSE;
  });
}

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