Same filename and directory in other branches
- 8.9.x core/modules/system/tests/modules/theme_test/src/ThemeTestController.php
- 9 core/modules/system/tests/modules/theme_test/src/ThemeTestController.php
Namespace
Drupal\theme_test
File
core/modules/system/tests/modules/theme_test/src/ThemeTestController.php
View source
<?php
namespace Drupal\theme_test;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\JsonResponse;
class ThemeTestController extends ControllerBase {
public function testInfoStylesheets() {
return [
'#attached' => [
'library' => [
'theme_test/theme_stylesheets_override_and_remove_test',
],
],
];
}
public function testTemplate() {
return [
'#markup' => \Drupal::theme()
->render('theme_test_template_test', []),
];
}
public function testInlineTemplate() {
$element = [];
$element['test'] = [
'#type' => 'inline_template',
'#template' => 'test-with-context {{ llama }}',
'#context' => [
'llama' => 'social',
],
];
return $element;
}
public function testSuggestion() {
return [
'#markup' => \Drupal::theme()
->render([
'theme_test__suggestion',
'theme_test',
], []),
];
}
public function testRequestListener() {
return [
'#markup' => $GLOBALS['theme_test_output'],
];
}
public function suggestionProvided() {
return [
'#theme' => 'theme_test_suggestion_provided',
];
}
public function suggestionAlter() {
return [
'#theme' => 'theme_test_suggestions',
];
}
public function generalSuggestionAlter() {
return [
'#theme' => 'theme_test_general_suggestions',
];
}
public function specificSuggestionAlter() {
return [
'#theme' => 'theme_test_specific_suggestions__variant',
];
}
public function nonHtml() {
$theme_initialized = \Drupal::theme()
->hasActiveTheme();
return new JsonResponse([
'theme_initialized' => $theme_initialized,
]);
}
public function preprocessSuggestions() {
return [
[
'#theme' => 'theme_test_preprocess_suggestions',
'#foo' => 'suggestion',
],
[
'#theme' => 'theme_test_preprocess_suggestions',
'#foo' => 'kitten',
],
[
'#theme' => 'theme_test_preprocess_suggestions',
'#foo' => 'monkey',
],
[
'#theme' => 'theme_test_preprocess_suggestions__kitten__flamingo',
],
];
}
public function preprocessCallback() {
return [
'#theme' => 'theme_test_preprocess_callback',
];
}
public function testThemeClass() {
return [
'#theme' => 'theme_test_theme_class',
'#title' => 'Testing loading a class from a .theme file',
];
}
}
Classes