You are here

function total_control_modules_installed in Total Control Admin Dashboard 3.0.x

Same name and namespace in other branches
  1. 8.2 total_control.module \total_control_modules_installed()

Implements hook_modules_installed().

File

./total_control.module, line 23
Contains total_control.module.

Code

function total_control_modules_installed($modules) {

  // When we enable the Comment module we load the Drupal standard configs.
  // And the Total Control Comments view.
  if (in_array('comment', $modules)) {
    $comment_managed_optional_path = Drupal::service('module_handler')
      ->getModule('total_control')
      ->getPath() . '/config/managed/comment';

    // Drupal core standard profile configs for comment.
    $comment_managed_optional_configs = [
      'comment.type.comment',
      'field.field.comment.comment.comment_body',
      'rdf.mapping.comment.comment',
      'core.entity_form_display.comment.comment.default',
      'core.entity_view_display.comment.comment.default',
      'field.storage.node.comment',
      'views.view.control_comments',
    ];
    foreach ($comment_managed_optional_configs as $config_name) {
      $config_path = $comment_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);
    }
  }

  // When we enable the Taxonomy module then we add the Total Control Term view.
  if (in_array('taxonomy', $modules)) {
    $taxonomy_managed_optional_path = Drupal::service('module_handler')
      ->getModule('total_control')
      ->getPath() . '/config/managed/taxonomy';
    $taxonomy_managed_optional_configs = [
      'views.view.control_terms',
    ];
    foreach ($taxonomy_managed_optional_configs as $config_name) {
      $config_path = $taxonomy_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);
    }
  }
}