clean_maintenance-8.x-1.3/clean_maintenance.module

clean_maintenance.module
<?php

/**
 * @file
 * The main module file.
 */

use Drupal\Component\Render\FormattableMarkup;

/**
 * Implements hook_theme_registry_alter().
 */
function clean_maintenance_theme_registry_alter(&$theme_registry) {

  // Override the default maintenance template with our own.
  if (isset($theme_registry['maintenance_page'])) {

    // Get the current route.
    $current_route = \Drupal::routeMatch()->getRouteName();

    // Don't do anything on the update.php page.
    if (!empty($current_route) && $current_route !== 'system.db_update') {

      // Get the path to this module.
      $module_path = \Drupal::service('extension.list.module')->getPath('clean_maintenance');

      // Set the theme path and file path.
      $theme_registry['maintenance_page']['theme path'] = $module_path;
      $theme_registry['maintenance_page']['path'] = $module_path . '/templates';

      // Get the maintenance page variables.
      $variables = _clean_maintenance_get_maintenance_page_variables();

      // Add custom variables.
      $theme_registry['maintenance_page']['variables'] = $variables;
    }
  }
}

/**
 * Get the maintenance page variables.
 */
function _clean_maintenance_get_maintenance_page_variables() {

  // Load the site name out of configuration.
  $site_config = \Drupal::config('system.site');
  $site_name = $site_config->get('name');

  $maintenance_text = new FormattableMarkup(\Drupal::config('system.maintenance')->get('message'), [
    '@site' => $site_name,
  ]);

  // Return the array.
  return [
    'maintenance_text' => $maintenance_text,
    'site_name' => $site_name,
  ];
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc