You are here

function ds_field_formatter_settings_summary_alter in Display Suite 8.3

Same name and namespace in other branches
  1. 8.4 ds.module \ds_field_formatter_settings_summary_alter()
  2. 8.2 ds.module \ds_field_formatter_settings_summary_alter()

Implements hook_field_formatter_settings_summary_alter().

1 call to ds_field_formatter_settings_summary_alter()
ds_field_settings_summary in includes/field_ui.inc
Creates a summary for the field format configuration summary.

File

./ds.module, line 1048
Display Suite core functions.

Code

function ds_field_formatter_settings_summary_alter(&$summary, $context) {
  if (\Drupal::config('ds.settings')
    ->get('field_template')) {

    // Field template summary.
    $functions = Ds::getFieldLayoutOptions();
    $default_field_function = \Drupal::config('ds.settings')
      ->get('ft-default');
    $field = $context['field_definition'];
    if (isset($context['form_state'])) {

      /* @var $form_state FormStateInterface */
      $form_state = $context['form_state'];
      $plugin_settings = $form_state
        ->get('plugin_settings');
      $field_function = isset($plugin_settings[$field
        ->getName()]['ft']['id']) ? $plugin_settings[$field
        ->getName()]['ft']['id'] : $default_field_function;
    }
    else {
      $plugin_settings = $context['formatter']
        ->getThirdPartySetting('ds', 'ft');
      $field_function = isset($plugin_settings['id']) ? $plugin_settings['id'] : $default_field_function;
    }
    if (!isset($functions[$field_function])) {
      $field_function = $default_field_function;
    }
    $summary[] = 'Field template: ' . Html::escape($field_function);
  }
}