You are here

public function MiconLinkWidget::settingsSummary in Micon 2.x

Same name and namespace in other branches
  1. 8 micon_link/src/Plugin/Field/FieldWidget/MiconLinkWidget.php \Drupal\micon_link\Plugin\Field\FieldWidget\MiconLinkWidget::settingsSummary()

Returns a short summary for the current widget settings.

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

Return value

array A short summary of the widget settings.

Overrides LinkWidget::settingsSummary

File

micon_link/src/Plugin/Field/FieldWidget/MiconLinkWidget.php, line 162

Class

MiconLinkWidget
Plugin implementation of the 'link' widget.

Namespace

Drupal\micon_link\Plugin\Field\FieldWidget

Code

public function settingsSummary() {
  $summary = parent::settingsSummary();
  $enabled_packages = array_filter($this
    ->getSetting('packages'));
  if ($enabled_packages) {
    $enabled_packages = array_intersect_key(Micon::loadActiveLabels(), $enabled_packages);
    $summary[] = $this
      ->t('With icon packages: @packages', [
      '@packages' => implode(', ', $enabled_packages),
    ]);
  }
  else {
    $summary[] = $this
      ->t('With icon packages: @packages', [
      '@packages' => 'All',
    ]);
  }
  if ($icon = $this
    ->getSetting('icon')) {
    $summary[] = $this
      ->micon('Default icon: ')
      ->setIcon($icon)
      ->setIconAfter();
  }
  if ($this
    ->getSetting('target')) {
    $summary[] = $this
      ->t('Allow target selection');
  }
  return $summary;
}