Change record status: 
Project: 
Introduced in branch: 
8.x
Description: 

In Drupal 7, hook_field_formatter_settings_summary() needed to return a string. This has changed in Drupal 8 where the formatter::settingsSummary() now needs to return an array. This affects hook_field_formatter_settings_summary_alter() which now receives an array instead of a string.

Drupal 7

/**
 * Implements hook_field_formatter_settings_summary().
 */
function text_field_formatter_settings_summary($field, $instance, $view_mode) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];

  $summary = '';

  if (strpos($display['type'], '_trimmed') !== FALSE) {
    $summary = t('Trim length') . ': ' . $settings['trim_length'];
  }

  return $summary;
}

Drupal 8

  // From \Drupal\text\Plugin\field\formatter\TextTrimmedFormatter.
  public function settingsSummary() {
    $summary = array();
    $summary[] = t('Trim length: @trim_length', array('@trim_length' => $this->getSetting('trim_length')));
    return $summary;
  }
function hook_field_formatter_settings_summary_alter(&$summary, $context) {
  // Append a message to the summary when an instance of foo_field has
  // mysetting set to TRUE for the current view mode.
  if ($context['field']['type'] == 'foo_field') {
    if ($context['formatter']->getSetting('mysetting')) {
      $summary[] = t('My setting enabled.');
    }
  }
}
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done