Browse Source

Issue #3013136 by Majdi: Page title block always empty

merge-requests/4/head
Chi 6 years ago
parent
commit
2db5ea00a7
  1. 12
      src/TwigExtension.php
  2. 1
      tests/src/Functional/TwigTweakTest.php

12
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))

1
tests/src/Functional/TwigTweakTest.php

@ -57,7 +57,6 @@ class TwigTweakTest extends BrowserTestBase {
'breakpoint_group' => 'responsive_image',
])->save();
// Setup Russian.
ConfigurableLanguage::createFromLangcode('ru')->save();
}

Loading…
Cancel
Save