ThemeTestThemeHooks1.php
Namespace
Drupal\theme_test\HookFile
-
core/
modules/ system/ tests/ modules/ theme_test/ src/ Hook/ ThemeTestThemeHooks1.php
View source
<?php
declare (strict_types=1);
namespace Drupal\theme_test\Hook;
use Drupal\Core\Hook\Attribute\Hook;
/**
* Hook implementations for theme_test.
*/
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;
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
ThemeTestThemeHooks1 | Hook implementations for theme_test. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.