You are here

function varbase_seo_modules_installed in Varbase SEO 8.6

Same name and namespace in other branches
  1. 9.0.x varbase_seo.module \varbase_seo_modules_installed()

Implements hook_modules_installed().

File

./varbase_seo.module, line 48
Contains varbase_seo.module.

Code

function varbase_seo_modules_installed($modules) {

  // When we enable the Google Analytics module we load the custom GA settings.
  if (in_array('google_analytics', $modules)) {
    $google_analytics_managed_optional_path = Drupal::service('module_handler')
      ->getModule('varbase_seo')
      ->getPath() . '/config/managed/google_analytics';

    // Varbase SEO custom google analytics config settings.
    $google_analytics_managed_optional_configs = [
      'google_analytics.settings',
    ];
    foreach ($google_analytics_managed_optional_configs as $config_name) {
      $config_path = $google_analytics_managed_optional_path . '/' . $config_name . '.yml';
      $config_content = file_get_contents($config_path);
      $config_data = (array) Yaml::parse($config_content);
      $config_factory = \Drupal::configFactory()
        ->getEditable($config_name);
      $config_factory
        ->setData($config_data)
        ->save(TRUE);
    }
  }
}