You are here

public function LinkTargetFieldWidget::settingsSummary in Link target 8

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

src/Plugin/Field/FieldWidget/LinkTargetFieldWidget.php, line 51

Class

LinkTargetFieldWidget
Plugin implementation of the 'link_target_field_widget' widget.

Namespace

Drupal\link_target\Plugin\Field\FieldWidget

Code

public function settingsSummary() {
  $summary = parent::settingsSummary();
  $targets_conf = $this
    ->getSelectedOptions();
  if ($targets_conf) {

    // Clear out any zeros saved for unchecked values.
    foreach ($targets_conf as $key => $val) {
      if (!$val) {
        unset($targets_conf[$key]);
      }
    }
    $summary[] = !empty($targets_conf) ? $this
      ->t('Available targets:') . ' ' . implode(', ', $targets_conf) : $this
      ->t('No target options were selected.');
  }
  else {
    $summary[] = $this
      ->t('All targets will be available.');
  }
  return $summary;
}