utilikit-1.0.0/modules/utilikit_help/utilikit_help.module

modules/utilikit_help/utilikit_help.module
<?php

/**
 * @file
 * UtiliKit Help module - Comprehensive documentation and help system.
 *
 * Provides an interactive, user-friendly documentation system for UtiliKit
 * with real-life examples, responsive design, and accessible navigation.
 */

declare(strict_types=1);

use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 *
 * Provides contextual help throughout the Drupal admin interface.
 */
function utilikit_help_help(string $route_name, RouteMatchInterface $route_match): ?string {
  if ($route_name === 'help.page.utilikit_help') {
    return _utilikit_helper_render_readme();
  }
  return NULL;
}

/**
 * Implements hook_theme().
 */
function utilikit_help_theme($existing, $type, $theme, $path): array {
  return [
    'utilikit_help_page' => [
      'variables' => [],
      'template' => 'utilikit-help-page',
    ],
  ];
}

/**
 * Implements hook_page_attachments().
 */
function utilikit_help_page_attachments(array &$attachments): void {
  $route_name = \Drupal::routeMatch()->getRouteName();

  // Only attach on help pages.
  if ($route_name !== 'utilikit_help.documentation') {
    return;
  }

  // Get main module settings.
  $config = \Drupal::config('utilikit.settings');

  // Force inline mode for help examples.
  $attachments['#attached']['drupalSettings']['utilikit'] = [
    'devMode' => (bool) $config->get('dev_mode'),
    'showPageErrors' => (bool) $config->get('show_page_errors'),
    'enableTransitions' => (bool) $config->get('enable_transitions'),
    'debounce' => (int) ($config->get('debounce') ?? 50),
    'logLevel' => $config->get('log_level') ?? 'warnings',
    'adminPreview' => (bool) $config->get('admin_preview'),
    'activeBreakpoints' => ['sm', 'md', 'lg', 'xl', 'xxl'],
    // ALWAYS inline for help examples.
    'renderingMode' => 'inline',
    'csrfToken' => \Drupal::csrfToken()->get('utilikit-update-css'),
    'breakpoints' => [
      'sm' => 576,
      'md' => 768,
      'lg' => 992,
      'xl' => 1200,
      'xxl' => 1400,
    ],
  ];

  // Always attach inline engine for help page.
  $attachments['#attached']['library'][] = 'utilikit/utilikit.engine';
  $attachments['#attached']['library'][] = 'utilikit_help/help';

  if ($config->get('show_page_errors')) {
    $attachments['#attached']['library'][] = 'utilikit/utilikit.engine.message';
  }

  if ($config->get('dev_mode')) {
    $attachments['#attached']['library'][] = 'utilikit/utilikit.debug';
  }
}

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

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