public function RenderAs::as in Twig Extender 8.2
Same name and namespace in other branches
- 8.4 src/Plugin/TwigPlugin/RenderAs.php \Drupal\twig_extender\Plugin\TwigPlugin\RenderAs::as()
- 8.3 src/Plugin/TwigPlugin/RenderAs.php \Drupal\twig_extender\Plugin\TwigPlugin\RenderAs::as()
- 4.x src/Plugin/TwigPlugin/RenderAs.php \Drupal\twig_extender\Plugin\TwigPlugin\RenderAs::as()
Implementation for render block.
File
- src/
Plugin/ TwigPlugin/ RenderAs.php, line 23
Class
- RenderAs
- The plugin for check authenticated user.
Namespace
Drupal\twig_extender\Plugin\TwigPluginCode
public function as($element, $suggestion) {
if (!empty($element['#theme'])) {
if (!is_iterable($element['#theme'])) {
$element['#theme'] = [
$element['#theme'],
];
}
$base_theme_hook = end($element['#theme']);
$suggestion = str_replace('-', '_', $suggestion);
array_unshift($element['#theme'], "{$base_theme_hook}__{$suggestion}");
}
return $element;
}