You are here

public function RenderAs::as in Twig Extender 8.3

Same name and namespace in other branches
  1. 8.4 src/Plugin/TwigPlugin/RenderAs.php \Drupal\twig_extender\Plugin\TwigPlugin\RenderAs::as()
  2. 8.2 src/Plugin/TwigPlugin/RenderAs.php \Drupal\twig_extender\Plugin\TwigPlugin\RenderAs::as()
  3. 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\TwigPlugin

Code

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;
}