You are here

public function ExifWidgetBase::settingsSummary in Exif 8

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

1 call to ExifWidgetBase::settingsSummary()
ExifFieldWidgetBase::settingsSummary in src/Plugin/Field/FieldWidget/ExifFieldWidgetBase.php
Returns a short summary for the current widget settings.
1 method overrides ExifWidgetBase::settingsSummary()
ExifFieldWidgetBase::settingsSummary in src/Plugin/Field/FieldWidget/ExifFieldWidgetBase.php
Returns a short summary for the current widget settings.

File

src/Plugin/Field/FieldWidget/ExifWidgetBase.php, line 92

Class

ExifWidgetBase
Base class for 'Exif Field widget' plugin implementations.

Namespace

Drupal\exif\Plugin\Field\FieldWidget

Code

public function settingsSummary() {
  $summary = parent::settingsSummary();
  $image_field = $this
    ->getSetting('image_field');
  if (isset($image_field)) {
    $bundle_name = $this->fieldDefinition
      ->getTargetBundle();
    $entity_type = $this->fieldDefinition
      ->getTargetEntityTypeId();
    $image_field_config = Drupal::getContainer()
      ->get('entity_field.manager')
      ->getFieldDefinitions($entity_type, $bundle_name)[$image_field];
    if ($image_field_config instanceof FieldConfig) {
      if ($image_field_config
        ->getType() == "image" || $image_field_config
        ->getType() == "media") {
        $label = t("'@image_linked_label' (id: @image_linked_id)", [
          '@image_linked_label' => $image_field_config
            ->getLabel(),
          '@image_linked_id' => $image_field,
        ]);
      }
      else {
        $label = $image_field;
      }
    }
    $image_field_msg = t("exif will be extracted from image field @image", [
      '@image' => $label,
    ]);
  }
  else {
    $image_field_msg = t('No image chosen. field will stay empty.');
  }
  array_unshift($summary, $image_field_msg);
  return $summary;
}