Same name and namespace in other branches
  1. 8.x-2.x src/Plugin/Field/FieldWidget/ExifWidgetBase.php \Drupal\exif\Plugin\Field\FieldWidget\ExifWidgetBase::settingsSummary() 1 comment
1 method overrides ExifWidgetBase::settingsSummary()
ExifFieldWidgetBase::settingsSummary in src/Plugin/Field/FieldWidget/ExifFieldWidgetBase.php

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;
}