You are here

better_social_sharing_buttons.install in Better Social Sharing Buttons 8.3

Install file for updates between versions.

File

better_social_sharing_buttons.install
View source
<?php

/**
 * @file
 * Install file for updates between versions.
 */

/**
 * Updates services and settings configuration.
 */
function better_social_sharing_buttons_update_8001() {
  $config_factory = \Drupal::configFactory();
  $config = $config_factory
    ->getEditable('better_social_sharing_buttons.settings');
  $services = $config
    ->get('services');
  if (!$services) {
    $services = [
      'facebook' => 'facebook',
      'twitter' => 'twitter',
      'linkedin' => 'linkedin',
      'email' => 'email',
    ];
  }
  else {
    unset($services['googleplus']);
    unset($services['delicious']);
    $services['print'] = 0;
  }
  $config
    ->set('services', $services);
  $config
    ->set('print_css', '');
  $config
    ->clear('height');
  if (!$config
    ->get('width')) {
    $config
      ->set('width', '20px');
  }
  if (!$config
    ->get('radius')) {
    $config
      ->set('radius', '3px');
  }
  $config
    ->save(TRUE);
}

/**
 * Removes slashdot service configuration.
 */
function better_social_sharing_buttons_update_8002() {
  $config_factory = \Drupal::configFactory();
  $config = $config_factory
    ->getEditable('better_social_sharing_buttons.settings');
  $config
    ->clear('services.slashdot')
    ->save();
}

/**
 * Removes stumbleupon service configuration.
 */
function better_social_sharing_buttons_update_8003() {
  $config_factory = \Drupal::configFactory();
  $config = $config_factory
    ->getEditable('better_social_sharing_buttons.settings');
  $config
    ->clear('services.stumbleupon')
    ->save();
}

Functions

Namesort descending Description
better_social_sharing_buttons_update_8001 Updates services and settings configuration.
better_social_sharing_buttons_update_8002 Removes slashdot service configuration.
better_social_sharing_buttons_update_8003 Removes stumbleupon service configuration.