Issue #2095223 by pwolanin, tim.plunkett: Remove t() from LocalTaskDefault now that it's in PluginBase.
parent
94ca8a1496
commit
3210323955
|
@ -10,7 +10,6 @@ namespace Drupal\Core\Menu;
|
||||||
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 @@ use Symfony\Component\HttpFoundation\Request;
|
||||||
*/
|
*/
|
||||||
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
|
||||||
* 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 @@ class LocalTaskDefault extends PluginBase implements LocalTaskInterface, Contain
|
||||||
$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 @@
|
||||||
|
|
||||||
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 @@ class LocalTaskDefaultTest extends UnitTestCase {
|
||||||
* 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue