You are here

function file_browser_update_8002 in File Entity Browser 8

Updates entity browser configuration to update outdated values.

File

./file_browser.install, line 118
Defines library requirements and install routines for File Browser.

Code

function file_browser_update_8002() {

  /** @var \Drupal\Core\Config\ConfigFactoryInterface $config_factory */
  $config_factory = \Drupal::service('config.factory');
  $list = $config_factory
    ->listAll('entity_browser.browser');
  foreach ([
    'entity_browser.browser.browse_files',
    'entity_browser.browser.browse_files_modal',
  ] as $name) {
    if (in_array($name, $list, TRUE)) {
      $entity_browser = $config_factory
        ->getEditable($name);
      $entity_browser
        ->set('selection_display_configuration.selection_hidden', FALSE);
      if ($entity_browser
        ->get('widgets.a4ad947c-9669-497c-9988-24351955a02f')) {
        $entity_browser
          ->set('widgets.a4ad947c-9669-497c-9988-24351955a02f.settings.auto_select', TRUE);
      }
      $entity_browser
        ->save();
    }
  }

  /** @var \Drupal\image\Entity\ImageStyle $image_style */
  if ($image_style = ImageStyle::load('file_entity_browser_small')) {
    $effect = $image_style
      ->getEffect('374fe20a-a27c-45f5-b76d-d851cabcf7b0');
    $effect
      ->setConfiguration([
      'uuid' => '374fe20a-a27c-45f5-b76d-d851cabcf7b0',
      'id' => 'image_scale_and_crop',
      'weight' => 1,
      'data' => [
        'width' => 100,
        'height' => 100,
      ],
    ]);
    $image_style
      ->save();
  }
}