preprocess-2.0.0/preprocess.module

preprocess.module
<?php

/**
 * @file
 * Handles preprocessing of all theme hooks implemented as templates.
 */

/**
 * Implements hook_help().
 */
function preprocess_help(string $route_name): string {
  return $route_name === 'help.page.preprocess' ?
    sprintf('<pre>%s</pre>', file_get_contents(__DIR__ . '/README.md')) :
    '';
}

/**
 * Implements hook_preprocess().
 */
function preprocess_preprocess(&$variables, $hook): void {
  /** @var Drupal\preprocess\PreprocessManagerInterface $manager */
  $manager = Drupal::service('preprocess.manager');
  $variables = $manager->preprocess($hook, $variables);
}

/**
 * Implements hook_theme_registry_alter().
 */
function preprocess_theme_registry_alter(array &$theme_registry): void {
  $implementation = 'preprocess_preprocess';
  foreach ($theme_registry as $theme => $item) {
    $preprocessor_key = array_search($implementation, $item['preprocess functions'] ?? [], TRUE);
    if ($preprocessor_key === FALSE) {
      continue;
    }

    unset($theme_registry[$theme]['preprocess functions'][$preprocessor_key]);
    $theme_registry[$theme]['preprocess functions'][] = $implementation;
  }
}

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

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