You are here

function linkedin_insights_tag_update_8001 in LinkedIn Insights Tag 8

Implements hook_update_N().

Move any existing settings values to new locations and empty out the old locations.

File

./linked_insights_tag.install, line 14
Install, update hooks for the linkedin_insights_tag module.

Code

function linkedin_insights_tag_update_8001() {
  $config_factory = \Drupal::configFactory();
  $config = $config_factory
    ->getEditable('linkedin_insight_tag.settings');
  $migrate_config_items = [
    'data.user_role_roles' => 'user_role_roles',
    'data.partner_id' => 'partner_id',
    'data.noscript' => 'image_only',
  ];
  foreach ($migrate_config_items as $old_key => $new_key) {
    $existing_value = $config
      ->get($old_key);
    if (!empty($existing_value)) {
      $config
        ->set($new_key, $existing_value);
    }
    $config
      ->set($old_key, NULL);
  }
  $config
    ->save(TRUE);
}