diff --git a/core/lib/Drupal/Core/Menu/LocalTaskDefault.php b/core/lib/Drupal/Core/Menu/LocalTaskDefault.php index 44233e8..67e0afd 100644 --- a/core/lib/Drupal/Core/Menu/LocalTaskDefault.php +++ b/core/lib/Drupal/Core/Menu/LocalTaskDefault.php @@ -10,7 +10,6 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\PluginBase; use Drupal\Core\Routing\RouteProviderInterface; -use Drupal\Core\StringTranslation\TranslationInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; @@ -20,13 +19,6 @@ class LocalTaskDefault extends PluginBase implements LocalTaskInterface, ContainerFactoryPluginInterface { /** - * String translation object. - * - * @var \Drupal\Core\StringTranslation\TranslationInterface - */ - protected $stringTranslation; - - /** * The route provider to load routes by name. * * @var \Drupal\Core\Routing\RouteProviderInterface @@ -49,13 +41,10 @@ class LocalTaskDefault extends PluginBase implements LocalTaskInterface, Contain * The plugin_id for the plugin instance. * @param array $plugin_definition * The plugin implementation definition. - * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation - * The string translation object. * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider * The route provider. */ - public function __construct(array $configuration, $plugin_id, array $plugin_definition, TranslationInterface $string_translation, RouteProviderInterface $route_provider) { - $this->stringTranslation = $string_translation; + public function __construct(array $configuration, $plugin_id, array $plugin_definition, RouteProviderInterface $route_provider) { $this->routeProvider = $route_provider; parent::__construct($configuration, $plugin_id, $plugin_definition); } @@ -68,21 +57,11 @@ public static function create(ContainerInterface $container, array $configuratio $configuration, $plugin_id, $plugin_definition, - $container->get('string_translation'), $container->get('router.route_provider') ); } /** - * Translates a string to the current language or to a given language. - * - * See the t() documentation for details. - */ - protected function t($string, array $args = array(), array $options = array()) { - return $this->stringTranslation->translate($string, $args, $options); - } - - /** * {@inheritdoc} */ public function getRouteName() { diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php index 6a7c8af..1777ab8 100644 --- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php @@ -7,6 +7,7 @@ namespace Drupal\Tests\Core\Menu; +use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\Menu\LocalTaskDefault; use Drupal\Tests\UnitTestCase; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; @@ -83,7 +84,10 @@ protected function setUp() { * Setups the local task default. */ protected function setupLocalTaskDefault() { - $this->localTaskBase = new LocalTaskDefault($this->config, $this->pluginId, $this->pluginDefinition, $this->stringTranslation, $this->routeProvider); + $container = new ContainerBuilder(); + $container->set('string_translation', $this->stringTranslation); + \Drupal::setContainer($container); + $this->localTaskBase = new LocalTaskDefault($this->config, $this->pluginId, $this->pluginDefinition, $this->routeProvider); } /**