You are here

varbase_total_control.install in Varbase Total Control Dashboard 8

Install, update and uninstall functions for the Varbase Dahsboard module.

File

varbase_total_control.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the Varbase Dahsboard module.
 */
use Symfony\Component\Yaml\Yaml;

/**
 * Implements hook_install().
 *
 * @see system_install()
 */
function varbase_total_control_install() {

  // Enable Google Analytics Reports API
  if (!\Drupal::moduleHandler()
    ->moduleExists('google_analytics_reports_api')) {
    \Drupal::service('module_installer')
      ->install([
      'google_analytics_reports_api',
    ], FALSE);
  }

  // Enable Google Analytics Reports
  if (!\Drupal::moduleHandler()
    ->moduleExists('google_analytics_reports')) {
    \Drupal::service('module_installer')
      ->install([
      'google_analytics_reports',
    ], FALSE);
  }

  // Enable Charts
  if (!\Drupal::moduleHandler()
    ->moduleExists('charts')) {
    \Drupal::service('module_installer')
      ->install([
      'charts',
    ], FALSE);
  }

  // Enable Charts Highcharts
  if (!\Drupal::moduleHandler()
    ->moduleExists('charts_highcharts')) {
    \Drupal::service('module_installer')
      ->install([
      'charts_highcharts',
    ], FALSE);
  }
  $module_path = Drupal::service('module_handler')
    ->getModule('varbase_total_control')
    ->getPath();
  $optional_configs = [
    'views.view.varbase_google_analytics_summary',
    'page_manager.page_variant.total_control_dashboard-panels_variant-0',
    'page_manager.page_variant.total_control_dashboard-panels_variant-1',
  ];
  foreach ($optional_configs as $optional_config) {
    $config_path = $module_path . '/config/optional/' . $optional_config . '.yml';
    $config_content = file_get_contents($config_path);
    $config_data = (array) Yaml::parse($config_content);
    $config_factory = \Drupal::configFactory()
      ->getEditable($optional_config);
    $config_factory
      ->setData($config_data)
      ->save(TRUE);
  }
}

Functions

Namesort descending Description
varbase_total_control_install Implements hook_install().