You are here

public function ExifFieldWidgetBase::settingsSummary in Exif 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldWidget/ExifFieldWidgetBase.php \Drupal\exif\Plugin\Field\FieldWidget\ExifFieldWidgetBase::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 ExifWidgetBase::settingsSummary

File

src/Plugin/Field/FieldWidget/ExifFieldWidgetBase.php, line 141

Class

ExifFieldWidgetBase
Class ExifFieldWidgetBase provide base methods for all widgets.

Namespace

Drupal\exif\Plugin\Field\FieldWidget

Code

public function settingsSummary() {
  $summary = parent::settingsSummary();
  $exif_field_separator = $this
    ->getSetting('exif_field_separator');
  if (isset($exif_field_separator) && strlen($exif_field_separator) == 1) {
    $exif_field_msg = t("exif value will be split using character separator '@separator'", [
      '@separator' => $exif_field_separator,
    ]);
  }
  else {
    $exif_field_msg = t('exif value will be extracted as one value');
  }
  array_unshift($summary, $exif_field_msg);
  $exif_field = $this
    ->getSetting('exif_field');
  if (isset($exif_field) && $exif_field != 'naming_convention') {
    $exif_field_msg = t("exif data will be extracted from image metadata field '@metadata'", [
      '@metadata' => $exif_field,
    ]);
  }
  else {
    $fieldname = $this->fieldDefinition
      ->getName();
    $exif_field = str_replace("field_", "", $fieldname);
    $exif_field_msg = t("Using naming convention. so the exif data will be extracted from image metadata field '@metadata'", [
      '@metadata' => $exif_field,
    ]);
  }
  array_unshift($summary, $exif_field_msg);
  return $summary;
}