You are here

public function ButtonLinkFormatter::settingsSummary in Button Link Formatter 8

Returns a short summary for the current formatter settings.

If an empty result is returned, a UI can still be provided to display a settings form in case the formatter has configurable settings.

Return value

string[] A short summary of the formatter settings.

Overrides LinkFormatter::settingsSummary

File

src/Plugin/Field/FieldFormatter/ButtonLinkFormatter.php, line 107

Class

ButtonLinkFormatter
Plugin implementation of the 'link_separate' formatter.

Namespace

Drupal\button_link\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $settings = $this
    ->getSettings();
  $summary[] = $this
    ->t('Button type: @text', [
    '@text' => $settings['btn_type'],
  ]);
  if (!empty($settings['btn_size'])) {
    $summary[] = $this
      ->t('Button size: @text', [
      '@text' => $settings['btn_size'],
    ]);
  }
  if (!empty($settings['link_text'])) {
    $summary[] = $this
      ->t('Link text: @text', [
      '@text' => $settings['link_text'],
    ]);
  }
  if (!empty($settings['rel'])) {
    $summary[] = $this
      ->t('Add rel="@rel"', [
      '@rel' => $settings['rel'],
    ]);
  }
  if (!empty($settings['btn_block'])) {
    $summary[] = $this
      ->t('Block level button: @text', [
      '@text' => $settings['btn_block'],
    ]);
  }
  if (!empty($settings['icon_class'])) {
    $summary[] = $this
      ->t('Icon class: "@rel"', [
      '@rel' => $settings['icon_class'],
    ]);
  }
  if (!empty($settings['target'])) {
    $summary[] = $this
      ->t('Open link in new window');
  }
  return $summary;
}