Browse Source

Issue #2913809 by julien.sibi: Ouput drupal_region() function using region's Twig template

merge-requests/4/head
julien.sibi 7 years ago committed by Chi
parent
commit
25d45394e7
  1. 9
      src/TwigExtension.php

9
src/TwigExtension.php

@ -93,11 +93,13 @@ class TwigExtension extends \Twig_Extension {
* @param string $theme * @param string $theme
* (Optional) The name of the theme to load the region. If it is not * (Optional) The name of the theme to load the region. If it is not
* provided then default theme will be used. * provided then default theme will be used.
* @param bool $include_template
* (Optional) Render the output using the region's Twig template.
* *
* @return array * @return array
* A render array to display the region content. * A render array to display the region content.
*/ */
public function drupalRegion($region, $theme = NULL) { public function drupalRegion($region, $theme = NULL, $include_template = FALSE) {
$entity_type_manager = \Drupal::entityTypeManager(); $entity_type_manager = \Drupal::entityTypeManager();
$blocks = $entity_type_manager->getStorage('block')->loadByProperties([ $blocks = $entity_type_manager->getStorage('block')->loadByProperties([
'region' => $region, 'region' => $region,
@ -122,6 +124,11 @@ class TwigExtension extends \Twig_Extension {
} }
} }
if ($include_template) {
$build['#region'] = $region;
$build['#theme_wrappers'] = ['region'];
}
return $build; return $build;
} }

Loading…
Cancel
Save