You are here

function dropzonejs_eb_widget_update_8202 in DropzoneJS 8.2

Update configurations for new keys.

File

modules/eb_widget/dropzonejs_eb_widget.install, line 72
Install function hooks for the DropzoneJS entity browser widget module.

Code

function dropzonejs_eb_widget_update_8202() {

  /** @var \Drupal\entity_browser\Entity\EntityBrowser[] $entity_browsers */
  $entity_browsers = EntityBrowser::loadMultiple();
  foreach ($entity_browsers as $entity_browser) {

    /** @var \Drupal\entity_browser\WidgetInterface[] $widgets */
    $widgets = $entity_browser
      ->getWidgets();
    $has_config_changes = FALSE;
    foreach ($widgets as $widget) {
      if ($widget instanceof DropzoneJsEbWidget) {
        $config = $widget
          ->getConfiguration();
        $config['settings']['clientside_resize'] = FALSE;
        $config['settings']['resize_height'] = 0;
        $config['settings']['resize_method'] = 'contain';
        $config['settings']['resize_quality'] = 1.0;
        $config['settings']['resize_width'] = 0;
        $config['settings']['thumbnail_method'] = 'contain';
        $widget
          ->setConfiguration($config);
        $has_config_changes = TRUE;
      }
    }
    if ($has_config_changes) {
      $entity_browser
        ->save();
    }
  }
}