You are here

public function BackgroundMedia::getFieldsByBundle in Bootstrap Styles 1.0.x

1 call to BackgroundMedia::getFieldsByBundle()
BackgroundMedia::buildConfigurationForm in src/Plugin/BootstrapStyles/Style/BackgroundMedia.php

File

src/Plugin/BootstrapStyles/Style/BackgroundMedia.php, line 168

Class

BackgroundMedia
Class BackgroundMedia.

Namespace

Drupal\bootstrap_styles\Plugin\BootstrapStyles\Style

Code

public function getFieldsByBundle($bundle) {
  $field_map = \Drupal::service('entity_field.manager')
    ->getFieldMap();
  $media_field_map = $field_map['media'];
  $fields = [];
  foreach ($media_field_map as $field_name => $field_info) {
    if (in_array($bundle, $field_info['bundles']) && in_array($field_info['type'], [
      'image',
      'file',
    ]) && $field_name !== 'thumbnail') {
      $fields[$field_name] = $field_name;
    }
  }
  return $fields;
}