From 44fa8d13f1d99994b081bac81ed91c554ebbe29f Mon Sep 17 00:00:00 2001 From: Lee Mills <8024370+millnut@users.noreply.github.com> Date: Sun, 16 Jun 2024 12:18:27 +0100 Subject: [PATCH] fix: Drupal 11 support --- localgov_base.info.yml | 2 +- localgov_base.theme | 12 +++++++++++- .../localgov_base_test_support.info.yml | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/localgov_base.info.yml b/localgov_base.info.yml index 38475efc..eca7def8 100644 --- a/localgov_base.info.yml +++ b/localgov_base.info.yml @@ -1,7 +1,7 @@ name: "LocalGov Base" description: "Base theme for LocalGov Drupal sites." type: theme -core_version_requirement: ^8.8 || ^9 || ^10 +core_version_requirement: ^10.1.3 || ^11 base theme: "stable9" ckeditor_stylesheets: - css/base/ckeditor.css diff --git a/localgov_base.theme b/localgov_base.theme index 56398b60..57ca9523 100644 --- a/localgov_base.theme +++ b/localgov_base.theme @@ -6,6 +6,7 @@ */ use Drupal\Component\Utility\Crypt; +use Drupal\Component\Utility\DeprecationHelper; use Drupal\Core\Form\FormStateInterface; use Drupal\views\ViewExecutable; @@ -69,7 +70,16 @@ function localgov_base_preprocess_page(&$variables) { continue; } $copy = $variables['page'][$region]; - $rendered = \Drupal::service('renderer')->renderPlain($copy); + + /** @var \Drupal\Core\Render\RendererInterface $renderer */ + $renderer = \Drupal::service('renderer'); + $rendered = DeprecationHelper::backwardsCompatibleCall( + currentVersion: \Drupal::VERSION, + deprecatedVersion: '10.3', + currentCallable: fn() => $renderer->renderInIsolation($copy), + deprecatedCallable: fn() => $renderer->renderPlain($copy), + ); + $variables['has_' . $region] = strlen(trim(strip_tags($rendered, '