From 6a4ea3d943ccec7f8709658ec3d5006feae18af7 Mon Sep 17 00:00:00 2001 From: Chi Date: Sat, 25 Nov 2017 15:35:39 +0500 Subject: [PATCH] Issue #2913809 by julien.sibi, Chi: Ouput drupal_region() function using region's Twig template. --- src/TwigExtension.php | 6 ++---- tests/src/Functional/TwigTweakTest.php | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/TwigExtension.php b/src/TwigExtension.php index 78db08c..857d88c 100644 --- a/src/TwigExtension.php +++ b/src/TwigExtension.php @@ -93,13 +93,11 @@ class TwigExtension extends \Twig_Extension { * @param string $theme * (Optional) The name of the theme to load the region. If it is not * provided then default theme will be used. - * @param bool $include_template - * (Optional) Render the output using the region's Twig template. * * @return array * A render array to display the region content. */ - public function drupalRegion($region, $theme = NULL, $include_template = FALSE) { + public function drupalRegion($region, $theme = NULL) { $entity_type_manager = \Drupal::entityTypeManager(); $blocks = $entity_type_manager->getStorage('block')->loadByProperties([ 'region' => $region, @@ -124,7 +122,7 @@ class TwigExtension extends \Twig_Extension { } } - if ($include_template) { + if ($build) { $build['#region'] = $region; $build['#theme_wrappers'] = ['region']; } diff --git a/tests/src/Functional/TwigTweakTest.php b/tests/src/Functional/TwigTweakTest.php index 17d62df..3f25b21 100644 --- a/tests/src/Functional/TwigTweakTest.php +++ b/tests/src/Functional/TwigTweakTest.php @@ -75,7 +75,7 @@ class TwigTweakTest extends BrowserTestBase { $this->assertByXpath($xpath); // Test region. - $xpath = '//div[@class = "tt-region"]'; + $xpath = '//div[@class = "tt-region"]/div[@class = "region region-sidebar-first"]'; $xpath .= '/div[contains(@class, "block-page-title-block") and h1[@class="page-title" and text() = "Log in"]]'; $xpath .= '/following-sibling::div[@class="messages messages--warning" and contains(., "Hi!")]'; $xpath .= '/following-sibling::div[contains(@class, "block-system-powered-by-block")]/span[. = "Powered by Drupal"]';