class TwigThemeTestController in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/tests/modules/twig_theme_test/src/TwigThemeTestController.php \Drupal\twig_theme_test\TwigThemeTestController
Controller routines for Twig theme test routes.
Hierarchy
- class \Drupal\twig_theme_test\TwigThemeTestController
Expanded class hierarchy of TwigThemeTestController
File
- core/
modules/ system/ tests/ modules/ twig_theme_test/ src/ TwigThemeTestController.php, line 16 - Contains \Drupal\twig_theme_test\TwigThemeTestController.
Namespace
Drupal\twig_theme_testView source
class TwigThemeTestController {
/**
* Menu callback for testing PHP variables in a Twig template.
*/
public function phpVariablesRender() {
return [
'#markup' => \Drupal::theme()
->render('twig_theme_test_php_variables', array()),
];
}
/**
* Menu callback for testing translation blocks in a Twig template.
*/
public function transBlockRender() {
return array(
'#theme' => 'twig_theme_test_trans',
);
}
/**
* Controller for testing the twig placeholder filter outside of {% trans %}
*/
public function placeholderOutsideTransRender() {
return [
'#theme' => 'twig_theme_test_placeholder_outside_trans',
'#var' => '<script>alert(123);</script>',
];
}
/**
* Renders for testing url_generator functions in a Twig template.
*/
public function urlGeneratorRender() {
return array(
'#theme' => 'twig_theme_test_url_generator',
);
}
/**
* Renders for testing link_generator functions in a Twig template.
*/
public function linkGeneratorRender() {
return [
'#theme' => 'twig_theme_test_link_generator',
'#test_url' => new Url('user.register', [], [
'absolute' => TRUE,
]),
'#test_url_attribute' => new Url('user.register', [], [
'attributes' => [
'foo' => 'bar',
],
]),
// Explicitly creating an Attribute object to avoid false positives when
// testing Attribute object merging with the twig link() function.
'#attributes' => new Attribute([
'class' => [
'llama',
'kitten',
'panda',
],
]),
];
}
/**
* Renders a URL to a string.
*/
public function urlToStringRender() {
return [
'#theme' => 'twig_theme_test_url_to_string',
'#test_url' => Url::fromRoute('user.register'),
];
}
/**
* Renders for testing file_url functions in a Twig template.
*/
public function fileUrlRender() {
return array(
'#theme' => 'twig_theme_test_file_url',
);
}
/**
* Renders for testing attach_library functions in a Twig template.
*/
public function attachLibraryRender() {
return array(
'#theme' => 'twig_theme_test_attach_library',
);
}
/**
* Menu callback for testing the Twig registry loader.
*/
public function registryLoaderRender() {
return array(
'#theme' => 'twig_registry_loader_test',
);
}
/**
* Controller for testing a renderable inside a template.
*/
public function renderable() {
return [
'#theme' => 'twig_theme_test_renderable',
'#renderable' => new ExampleRenderable(),
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TwigThemeTestController:: |
public | function | Renders for testing attach_library functions in a Twig template. | |
TwigThemeTestController:: |
public | function | Renders for testing file_url functions in a Twig template. | |
TwigThemeTestController:: |
public | function | Renders for testing link_generator functions in a Twig template. | |
TwigThemeTestController:: |
public | function | Menu callback for testing PHP variables in a Twig template. | |
TwigThemeTestController:: |
public | function | Controller for testing the twig placeholder filter outside of {% trans %} | |
TwigThemeTestController:: |
public | function | Menu callback for testing the Twig registry loader. | |
TwigThemeTestController:: |
public | function | Controller for testing a renderable inside a template. | |
TwigThemeTestController:: |
public | function | Menu callback for testing translation blocks in a Twig template. | |
TwigThemeTestController:: |
public | function | Renders for testing url_generator functions in a Twig template. | |
TwigThemeTestController:: |
public | function | Renders a URL to a string. |