You are here

linked_insights_tag.install in LinkedIn Insights Tag 8

Install, update hooks for the linkedin_insights_tag module.

File

linked_insights_tag.install
View source
<?php

/**
 * @file
 * Install, update hooks for the linkedin_insights_tag module.
 */

/**
 * Implements hook_update_N().
 *
 * Move any existing settings values to new locations and
 * empty out the old locations.
 */
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);
}

Functions