function big_pipe_theme_suggestions_big_pipe_interface_preview

Same name in other branches
  1. 10 core/modules/big_pipe/big_pipe.module \big_pipe_theme_suggestions_big_pipe_interface_preview()

Implements hook_theme_suggestions_HOOK().

1 call to big_pipe_theme_suggestions_big_pipe_interface_preview()
BigPipeInterfacePreviewThemeSuggestionsTest::testBigPipeThemeHookSuggestions in core/modules/big_pipe/tests/src/Kernel/BigPipeInterfacePreviewThemeSuggestionsTest.php
Tests template suggestions from big_pipe_theme_suggestions_big_pipe_interface_preview().

File

core/modules/big_pipe/big_pipe.module, line 10

Code

function big_pipe_theme_suggestions_big_pipe_interface_preview(array $variables) {
    $common_callbacks_simplified_suggestions = [
        'Drupal_block_BlockViewBuilder__lazyBuilder' => 'block',
    ];
    $suggestions = [];
    $suggestion = 'big_pipe_interface_preview';
    if ($variables['callback']) {
        $callback = preg_replace('/[^a-zA-Z0-9]/', '_', $variables['callback']);
        if (is_array($callback)) {
            $callback = implode('__', $callback);
        }
        // Use simplified template suggestion, if any.
        // For example, this simplifies
        // big-pipe-interface-preview--Drupal-block-BlockViewBuilder--lazyBuilder--<BLOCK ID>.html.twig
        // to
        // big-pipe-interface-preview--block--<BLOCK ID>.html.twig
        if (isset($common_callbacks_simplified_suggestions[$callback])) {
            $callback = $common_callbacks_simplified_suggestions[$callback];
        }
        $suggestions[] = $suggestion .= '__' . $callback;
        if (is_array($variables['arguments'])) {
            $arguments = preg_replace('/[^a-zA-Z0-9]/', '_', $variables['arguments']);
            foreach ($arguments as $argument) {
                if (empty($argument)) {
                    continue;
                }
                $suggestions[] = $suggestion . '__' . $argument;
            }
        }
    }
    return $suggestions;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.