function hook_preprocess_HOOK(&
$variables) { // This example is from node_preprocess_html(). It adds the node type to
// the body classes, when on an individual node page or node preview page.
if (($node = \Drupal::
routeMatch()->
getParameter('node'
)) || ($node = \Drupal::
routeMatch()->
getParameter('node_preview'
))) { if ($node instanceof NodeInterface
) { $variables['node_type'
] =
$node->
getType();
} }}/**
* Provides alternate named suggestions for a specific theme hook.
*
* This hook allows modules to provide alternative theme template name
* suggestions.
*
* HOOK is the least-specific version of the hook being called. For example, if
* '#theme' => 'node__article' is called, then hook_theme_suggestions_node()
* will be invoked, not hook_theme_suggestions_node__article(). The specific
* hook called (in this case 'node__article') is available in
* $variables['theme_hook_original'].
*
* Implementations of this hook must be placed in *.module or *.theme files, or
* must otherwise make sure that the hook implementation is available at
* any given time.
*
* Suggestions must begin with the value of HOOK, followed by two underscores to be discoverable.
*
* In the following example, we provide suggestions to
* node templates based bundle, id, and view mode.
*
* @code
* function node_theme_suggestions_node(array $variables) {
* $suggestions = [];
* $node = $variables['elements']['#node'];
* $sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
* $suggestions[] = 'node__' . $sanitized_view_mode;
* $suggestions[] = 'node__' . $node->bundle();
* $suggestions[] = 'node__' . $node->bundle() . '__' . $sanitized_view_mode;
* $suggestions[] = 'node__' . $node->id();
* $suggestions[] = 'node__' . $node->id() . '__' . $sanitized_view_mode;
*
* return $suggestions;
* }
*
* @endcode
*
* @param array $variables
* An array of variables passed to the theme hook. Note that this hook is
* invoked before any preprocessing.
*
* @return array
* An array of theme suggestions.
*
* @see hook_theme_suggestions_HOOK_alter()
*/