function varbase_total_control_install in Varbase Total Control Dashboard 8
Same name and namespace in other branches
- 8.6 varbase_total_control.install \varbase_total_control_install()
- 8.5 varbase_total_control.install \varbase_total_control_install()
- 9.0.x varbase_total_control.install \varbase_total_control_install()
Implements hook_install().
See also
File
- ./
varbase_total_control.install, line 15 - Install, update and uninstall functions for the Varbase Dahsboard module.
Code
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);
}
}