Unverified Commit ba5fb29f authored by Geoff Appleby's avatar Geoff Appleby
Browse files

Issue #3325434: Remove gacsp migration support

parent 66fc083b
Loading
Loading
Loading
Loading
+0 −46
Original line number Diff line number Diff line
@@ -5,52 +5,6 @@
 * Contains ga module installation and update hooks.
 */

use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
 * Implements hook_requirements().
 */
function ga_requirements($phase) {
  $requirements = [];

  if ($phase == 'runtime' && \Drupal::moduleHandler()->moduleExists('gacsp')) {
    $requirements['ga_gacsp'] = [
      'severity' => REQUIREMENT_WARNING,
      'title' => new TranslatableMarkup('gacsp module'),
      'value' => new TranslatableMarkup('Enabled'),
      'description' => new TranslatableMarkup('To prevent duplicate tracking, Googalytics will not activate until gacsp module is uninstalled.'),
    ];
  }

  return $requirements;
}

/**
 * Implements hook_install().
 */
function ga_install() {
  _ga_copy_gacsp_config();
}

/**
 * Copy config from gacsp if available.
 */
function _ga_copy_gacsp_config() {
  $gacspConfig = \Drupal::configFactory()
    ->getEditable('gacsp.settings')
    ->getRawData();

  if (!empty($gacspConfig)) {
    \Drupal::configFactory()->getEditable('ga.settings')
      ->setData($gacspConfig)
      ->set('premium', FALSE)
      ->set('sample_rate', 100)
      ->set('site_speed_sample_rate', 1)
      ->set('force_ssl', FALSE)
      ->save();
  }
}

/**
 * Add premium flag to configuration.
 */
+0 −5
Original line number Diff line number Diff line
@@ -13,11 +13,6 @@ use Drupal\ga\Event\CollectEvent;
 */
function ga_page_attachments(array &$attachments) {

  // Don't execute until gacsp module is uninstalled.
  if (\Drupal::moduleHandler()->moduleExists('gacsp')) {
    return;
  }

  /** @var \Drupal\ga\Event\CollectEvent $event */
  $event = \Drupal::service('event_dispatcher')
    ->dispatch(new CollectEvent(), AnalyticsEvents::COLLECT);