class ThemeTestThemeHooks1

Hook implementations for theme_test.

Hierarchy

Expanded class hierarchy of ThemeTestThemeHooks1

File

core/modules/system/tests/modules/theme_test/src/Hook/ThemeTestThemeHooks1.php, line 12

Namespace

Drupal\theme_test\Hook
View source
class ThemeTestThemeHooks1 {
  
  /**
   * Implements hook_preprocess_HOOK() for HTML document templates.
   */
  public function preprocessHtml(&$variables) : void {
    $variables['html_attributes']['theme_test_html_attribute'] = 'theme test html attribute value';
    $variables['attributes']['theme_test_body_attribute'] = 'theme test body attribute value';
    $variables['attributes']['theme_test_page_variable'] = 'Page variable is an array.';
  }
  
  /**
   * Implements hook_theme_suggestions_HOOK().
   */
  public function themeSuggestionsThemeTestPreprocessSuggestions($variables) : array {
    return [
      'theme_test_preprocess_suggestions__' . $variables['foo'],
    ];
  }
  
  /**
   * Implements hook_preprocess_HOOK().
   */
  public function preprocessThemeTestPreprocessSuggestions(&$variables) : void {
    $variables['foo'] = 'Theme hook implementor=theme_theme_test_preprocess_suggestions().';
  }
  
  /**
   * Implements hook_theme_suggestions_HOOK().
   */
  public function themeSuggestionsThemeTestSuggestionProvided(array $variables) : array {
    return [
      'theme_test_suggestion_provided__foo',
    ];
  }
  
  /**
   * Implements hook_theme_suggestions_HOOK().
   */
  public function themeSuggestionsNode(array $variables) : array {
    $xss = '<script type="text/javascript">alert(\'yo\');</script>';
    $suggestions[] = 'node__' . $xss;
    return $suggestions;
  }

}

Members

Title Sort descending Modifiers Object type Summary
ThemeTestThemeHooks1::preprocessHtml public function Implements hook_preprocess_HOOK() for HTML document templates.
ThemeTestThemeHooks1::preprocessThemeTestPreprocessSuggestions public function Implements hook_preprocess_HOOK().
ThemeTestThemeHooks1::themeSuggestionsNode public function Implements hook_theme_suggestions_HOOK().
ThemeTestThemeHooks1::themeSuggestionsThemeTestPreprocessSuggestions public function Implements hook_theme_suggestions_HOOK().
ThemeTestThemeHooks1::themeSuggestionsThemeTestSuggestionProvided public function Implements hook_theme_suggestions_HOOK().

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