You are here

protected function ExifWidgetBase::retrieveImageFieldFromBundle 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::retrieveImageFieldFromBundle()

Retrieve list of image field labels by key of image field.

Parameters

string $entity_type: Entity Type name.

string $bundle_name: Name bundle.

Return value

array Map of all images fields contained in this bundle by key and description.

1 call to ExifWidgetBase::retrieveImageFieldFromBundle()
ExifWidgetBase::settingsForm in src/Plugin/Field/FieldWidget/ExifWidgetBase.php
Returns a form to configure settings for the widget.

File

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

Class

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

Namespace

Drupal\exif\Plugin\Field\FieldWidget

Code

protected function retrieveImageFieldFromBundle($entity_type, $bundle_name) {
  $fields_of_bundle = Drupal::getContainer()
    ->get('entity_field.manager')
    ->getFieldDefinitions($entity_type, $bundle_name);
  $result = [];
  foreach ($fields_of_bundle as $key => $value) {
    if ($value instanceof FieldConfig) {
      if ($value
        ->getType() == "image" || $value
        ->getType() == "media") {
        $result[$key] = $value
          ->getLabel() . " (" . $key . ")";
      }
    }
  }
  return $result;
}