diff --git a/src/TwigExtension.php b/src/TwigExtension.php index b79a508..a9de162 100644 --- a/src/TwigExtension.php +++ b/src/TwigExtension.php @@ -116,6 +116,14 @@ class TwigExtension extends \Twig_Extension { return; } + // Title block needs special treatment. + if ($block_plugin instanceof TitleBlockPluginInterface) { + $request = \Drupal::request(); + $route_match = \Drupal::routeMatch(); + $title = \Drupal::service('title_resolver')->getTitle($request, $route_match->getRouteObject()); + $block_plugin->setTitle($title); + } + $content = $block_plugin->build(); if ($content && !Element::isEmpty($content)) { @@ -148,6 +156,10 @@ class TwigExtension extends \Twig_Extension { ]; } + if ($block_plugin instanceof TitleBlockPluginInterface) { + $build['#cache']['contexts'][] = 'url'; + } + if (!empty($content)) { CacheableMetadata::createFromRenderArray($build) ->merge(CacheableMetadata::createFromRenderArray($content)) diff --git a/tests/src/Functional/TwigTweakTest.php b/tests/src/Functional/TwigTweakTest.php index bdcf145..f313d63 100644 --- a/tests/src/Functional/TwigTweakTest.php +++ b/tests/src/Functional/TwigTweakTest.php @@ -57,7 +57,6 @@ class TwigTweakTest extends BrowserTestBase { 'breakpoint_group' => 'responsive_image', ])->save(); - // Setup Russian. ConfigurableLanguage::createFromLangcode('ru')->save(); }