From 67604e0923e32e9d72ee7058f0b7faf197c2124e Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Mon, 25 Mar 2024 08:42:46 +0000
Subject: [PATCH] Issue #3269141 by ameymudras, longwave, ravi.shankar,
 sharayurajput, catch, alexpott: Remove deprecated
 Drupal\Core\StringTranslation\TranslationWrapper to TranslatableMarkup in
 Drupal 11

---
 core/includes/bootstrap.inc                   |  5 ++++
 .../StringTranslation/TranslationWrapper.php  | 23 -------------------
 .../TranslationWrapperTest.php                |  6 ++---
 3 files changed, 7 insertions(+), 27 deletions(-)
 delete mode 100644 core/lib/Drupal/Core/StringTranslation/TranslationWrapper.php

diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 311967e40020..350bac908e32 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -61,6 +61,11 @@
  */
 define('DRUPAL_ROOT', dirname(__DIR__, 2));
 
+/**
+ * Keep backward compatibility for sites with references to TranslationWrapper.
+ */
+class_alias(TranslatableMarkup::class, '\Drupal\Core\StringTranslation\TranslationWrapper', TRUE);
+
 /**
  * Translates a string to the current language or to a given language.
  *
diff --git a/core/lib/Drupal/Core/StringTranslation/TranslationWrapper.php b/core/lib/Drupal/Core/StringTranslation/TranslationWrapper.php
deleted file mode 100644
index b68039779bcd..000000000000
--- a/core/lib/Drupal/Core/StringTranslation/TranslationWrapper.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-
-namespace Drupal\Core\StringTranslation;
-
-/**
- * Provides translatable string class.
- *
- * @deprecated in drupal:8.0.0 and is removed from drupal:11.0.0.
- *   Use the \Drupal\Core\StringTranslation\TranslatableMarkup class instead.
- *
- * @see https://www.drupal.org/node/2571255
- */
-class TranslationWrapper extends TranslatableMarkup {
-
-  /**
-   * {@inheritdoc}
-   */
-  public function __construct($string, array $arguments = [], array $options = [], TranslationInterface $string_translation = NULL) {
-    @trigger_error(__CLASS__ . ' is deprecated in drupal:8.0.0 and is removed from drupal:11.0.0. Use the \Drupal\Core\StringTranslation\TranslatableMarkup class instead. See https://www.drupal.org/node/2571255', E_USER_DEPRECATED);
-    parent::__construct($string, $arguments, $options, $string_translation);
-  }
-
-}
diff --git a/core/tests/Drupal/Tests/Core/StringTranslation/TranslationWrapperTest.php b/core/tests/Drupal/Tests/Core/StringTranslation/TranslationWrapperTest.php
index cec3d9970002..148503090764 100644
--- a/core/tests/Drupal/Tests/Core/StringTranslation/TranslationWrapperTest.php
+++ b/core/tests/Drupal/Tests/Core/StringTranslation/TranslationWrapperTest.php
@@ -9,7 +9,7 @@
 use Drupal\Tests\UnitTestCase;
 
 /**
- * Tests the TranslationWrapper class.
+ * Tests the TranslationWrapper backward compatibility layer.
  *
  * @coversDefaultClass \Drupal\Core\StringTranslation\TranslationWrapper
  * @group StringTranslation
@@ -18,11 +18,9 @@ class TranslationWrapperTest extends UnitTestCase {
 
   /**
    * @covers ::__construct
-   * @group legacy
    */
   public function testTranslationWrapper() {
-    $this->expectDeprecation('Drupal\Core\StringTranslation\TranslationWrapper is deprecated in drupal:8.0.0 and is removed from drupal:11.0.0. Use the \Drupal\Core\StringTranslation\TranslatableMarkup class instead. See https://www.drupal.org/node/2571255');
-    $object = new TranslationWrapper('Deprecated');
+    $object = new TranslationWrapper('Backward compatibility');
     $this->assertInstanceOf(TranslatableMarkup::class, $object);
   }
 
-- 
GitLab