You are here

function thunder_themes_installed in Thunder 8.5

Same name and namespace in other branches
  1. 8.2 thunder.profile \thunder_themes_installed()
  2. 8.3 thunder.profile \thunder_themes_installed()
  3. 8.4 thunder.profile \thunder_themes_installed()

Implements hook_themes_installed().

File

./thunder.profile, line 80
Enables modules and site configuration for a thunder site installation.

Code

function thunder_themes_installed($theme_list) {
  if (in_array('thunder_amp', $theme_list)) {

    // Install AMP module.
    \Drupal::service('module_installer')
      ->install([
      'amp',
    ], TRUE);
    \Drupal::configFactory()
      ->getEditable('amp.settings')
      ->set('amp_library_process_full_html', TRUE)
      ->save(TRUE);

    // Set AMP theme to thunder_amp,
    // if not set, or is one of the included themes.
    $ampThemeConfig = \Drupal::configFactory()
      ->getEditable('amp.theme');
    $ampTheme = $ampThemeConfig
      ->get('amptheme');
    if (empty($ampTheme) || $ampTheme == 'ampsubtheme_example' || $ampTheme == 'amptheme') {
      $ampThemeConfig
        ->set('amptheme', 'thunder_amp')
        ->save(TRUE);
    }

    // Disable unused blocks.

    /** @var \Drupal\block\Entity\Block[] $blocks */
    $blocks = Block::loadMultiple([
      'thunder_amp_account_menu',
      'thunder_amp_breadcrumbs',
      'thunder_amp_footer',
      'thunder_amp_local_actions',
      'thunder_amp_local_tasks',
      'thunder_amp_main_menu',
      'thunder_amp_messages',
      'thunder_amp_tools',
    ]);
    foreach ($blocks as $block) {
      $block
        ->disable()
        ->save();
    }
  }
  if (in_array('amptheme', $theme_list)) {
    \Drupal::service('module_installer')
      ->install([
      'amp',
    ], TRUE);
  }
}