RenderAs.php in Twig Extender 8.2
File
src/Plugin/TwigPlugin/RenderAs.php
View source
<?php
namespace Drupal\twig_extender\Plugin\TwigPlugin;
use Drupal\twig_extender\Plugin\Twig\TwigPluginBase;
class RenderAs extends TwigPluginBase {
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;
}
}
Classes
Name |
Description |
RenderAs |
The plugin for check authenticated user. |