You are here

google_optimize.install in Google Optimize 8

Installation file for Google Optimize module.

File

google_optimize.install
View source
<?php

/**
 * @file
 * Installation file for Google Optimize module.
 */

/**
 * Implements hook_install().
 *
 * Check that Google Analytics is installed and configured.
 */
function google_optimize_install() {
  $config = Drupal::config('google_analytics.settings');
  if (!$config
    ->get('account') ?: '') {
    Drupal::messenger()
      ->addError(t('Unable to get the Google Analytics account! Is Google Analytics installed and configured with your Google Analytics account ID?'));
  }
}

/**
 * Implements hook_uninstall().
 *
 * Remove config if module is uninstalled.
 */
function google_optimize_uninstall() {
  Drupal::configFactory()
    ->getEditable('google_optimize.settings')
    ->delete();
}

Functions