Skip to content
Snippets Groups Projects
Verified Commit 67604e09 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3269141 by ameymudras, longwave, ravi.shankar, sharayurajput, catch,...

Issue #3269141 by ameymudras, longwave, ravi.shankar, sharayurajput, catch, alexpott: Remove deprecated Drupal\Core\StringTranslation\TranslationWrapper to TranslatableMarkup in Drupal 11
parent 3d3b2c1d
No related branches found
No related tags found
No related merge requests found
...@@ -61,6 +61,11 @@ ...@@ -61,6 +61,11 @@
*/ */
define('DRUPAL_ROOT', dirname(__DIR__, 2)); 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. * Translates a string to the current language or to a given language.
* *
......
<?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);
}
}
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
use Drupal\Tests\UnitTestCase; use Drupal\Tests\UnitTestCase;
/** /**
* Tests the TranslationWrapper class. * Tests the TranslationWrapper backward compatibility layer.
* *
* @coversDefaultClass \Drupal\Core\StringTranslation\TranslationWrapper * @coversDefaultClass \Drupal\Core\StringTranslation\TranslationWrapper
* @group StringTranslation * @group StringTranslation
...@@ -18,11 +18,9 @@ class TranslationWrapperTest extends UnitTestCase { ...@@ -18,11 +18,9 @@ class TranslationWrapperTest extends UnitTestCase {
/** /**
* @covers ::__construct * @covers ::__construct
* @group legacy
*/ */
public function testTranslationWrapper() { 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('Backward compatibility');
$object = new TranslationWrapper('Deprecated');
$this->assertInstanceOf(TranslatableMarkup::class, $object); $this->assertInstanceOf(TranslatableMarkup::class, $object);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment