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

Issue #2095223 by pwolanin, tim.plunkett: Remove t() from LocalTaskDefault now...

Issue #2095223 by pwolanin, tim.plunkett: Remove t() from LocalTaskDefault now that it's in PluginBase.
parent 94ca8a14
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginBase; use Drupal\Core\Plugin\PluginBase;
use Drupal\Core\Routing\RouteProviderInterface; use Drupal\Core\Routing\RouteProviderInterface;
use Drupal\Core\StringTranslation\TranslationInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
...@@ -19,13 +18,6 @@ ...@@ -19,13 +18,6 @@
*/ */
class LocalTaskDefault extends PluginBase implements LocalTaskInterface, ContainerFactoryPluginInterface { 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. * The route provider to load routes by name.
* *
...@@ -49,13 +41,10 @@ class LocalTaskDefault extends PluginBase implements LocalTaskInterface, Contain ...@@ -49,13 +41,10 @@ class LocalTaskDefault extends PluginBase implements LocalTaskInterface, Contain
* The plugin_id for the plugin instance. * The plugin_id for the plugin instance.
* @param array $plugin_definition * @param array $plugin_definition
* The plugin implementation definition. * The plugin implementation definition.
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translation object.
* @param \Drupal\Core\Routing\RouteProviderInterface $route_provider * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider
* The route provider. * The route provider.
*/ */
public function __construct(array $configuration, $plugin_id, array $plugin_definition, TranslationInterface $string_translation, RouteProviderInterface $route_provider) { public function __construct(array $configuration, $plugin_id, array $plugin_definition, RouteProviderInterface $route_provider) {
$this->stringTranslation = $string_translation;
$this->routeProvider = $route_provider; $this->routeProvider = $route_provider;
parent::__construct($configuration, $plugin_id, $plugin_definition); parent::__construct($configuration, $plugin_id, $plugin_definition);
} }
...@@ -68,20 +57,10 @@ public static function create(ContainerInterface $container, array $configuratio ...@@ -68,20 +57,10 @@ public static function create(ContainerInterface $container, array $configuratio
$configuration, $configuration,
$plugin_id, $plugin_id,
$plugin_definition, $plugin_definition,
$container->get('string_translation'),
$container->get('router.route_provider') $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} * {@inheritdoc}
*/ */
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
namespace Drupal\Tests\Core\Menu; namespace Drupal\Tests\Core\Menu;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Menu\LocalTaskDefault; use Drupal\Core\Menu\LocalTaskDefault;
use Drupal\Tests\UnitTestCase; use Drupal\Tests\UnitTestCase;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
...@@ -83,7 +84,10 @@ protected function setUp() { ...@@ -83,7 +84,10 @@ protected function setUp() {
* Setups the local task default. * Setups the local task default.
*/ */
protected function setupLocalTaskDefault() { 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);
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment