You are here

function share_everywhere_update_8001 in Share Everywhere 2.x

Same name and namespace in other branches
  1. 8 share_everywhere.install \share_everywhere_update_8001()

Update the active configuration due to schema changes.

File

./share_everywhere.install, line 11
Install, update, and uninstall functions for the Share Everywhere module.

Code

function share_everywhere_update_8001() {
  $config = \Drupal::configFactory()
    ->getEditable('share_everywhere.settings');
  $config
    ->set('collapsible', intval($config
    ->get('collapsible')));
  $view_modes = $config
    ->get('view_modes');
  if ($view_modes) {
    foreach ($view_modes as $bundle => $bundle_view_modes) {
      $view_modes[$bundle] = array_map('strval', $bundle_view_modes);
    }
    $config
      ->set('view_modes', $view_modes);
  }
  $product_view_modes = $config
    ->get('product_view_modes');
  if ($product_view_modes) {
    foreach ($product_view_modes as $bundle => $bundle_view_modes) {
      $product_view_modes[$bundle] = array_map('strval', $bundle_view_modes);
    }
    $config
      ->set('product_view_modes', $product_view_modes);
  }
  $config
    ->save();
}