You are here

function thunder_media_update_8011 in Thunder 8.2

Remove "auto_select" from EB widget config, for those who don't support it.

File

modules/thunder_media/thunder_media.install, line 481
Contains.

Code

function thunder_media_update_8011() {

  /** @var \Drupal\entity_browser\Entity\EntityBrowser[] $browsers */
  $browsers = EntityBrowser::loadMultiple();
  foreach ($browsers as $browser) {
    $config = Drupal::configFactory()
      ->getEditable('entity_browser.browser.' . $browser
      ->getConfigTarget());
    foreach ($browser
      ->getWidgets() as $id => $widget) {
      if (!$widget
        ->getPluginDefinition()['auto_select']) {
        $config
          ->clear('widgets.' . $id . '.settings.auto_select');
      }
    }
    $config
      ->save();
  }
}