Commit deebed44 authored by webchick's avatar webchick

Issue #2087231 by tim.plunkett, pwolanin: Add a PluginBase in the Core...

Issue #2087231 by tim.plunkett, pwolanin: Add a PluginBase in the Core namespace with t() as a helper method.
parent ef2e45b0
......@@ -7,7 +7,7 @@
namespace Drupal\Core\Action;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Plugin\PluginBase;
use Drupal\Core\Action\ActionInterface;
/**
......
......@@ -7,9 +7,9 @@
namespace Drupal\Core\Menu;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Menu\LocalActionInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginBase;
use Drupal\Core\StringTranslation\Translator\TranslatorInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
......
......@@ -7,8 +7,8 @@
namespace Drupal\Core\Menu;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginBase;
use Drupal\Core\StringTranslation\TranslationInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
......
<?php
/**
* @file
* Contains \Drupal\Core\Plugin\PluginBase
*/
namespace Drupal\Core\Plugin;
use Drupal\Component\Plugin\PluginBase as ComponentPluginBase;
use Drupal\Core\StringTranslation\TranslationInterface;
/**
* Base class for plugins supporting metadata inspection and translation.
*/
abstract class PluginBase extends ComponentPluginBase {
/**
* The translation manager service.
*
* @var \Drupal\Core\StringTranslation\TranslationInterface
*/
protected $translationManager;
/**
* 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->translationManager()->translate($string, $args, $options);
}
/**
* Gets the translation manager.
*
* @return \Drupal\Core\StringTranslation\TranslationInterface
* The translation manager.
*/
protected function translationManager() {
if (!$this->translationManager) {
$this->translationManager = \Drupal::getContainer()->get('string_translation');
}
return $this->translationManager;
}
/**
* Sets the translation manager for this plugin.
*
* @param \Drupal\Core\StringTranslation\TranslationInterface $translation_manager
* The translation manager.
*
* @return self
* The plugin object.
*/
public function setTranslationManager(TranslationInterface $translation_manager) {
$this->translationManager = $translation_manager;
return $this;
}
}
......@@ -8,7 +8,7 @@
namespace Drupal\aggregator\Plugin;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Plugin\PluginBase;
use Drupal\Core\Plugin\PluginFormInterface;
/**
......
......@@ -7,7 +7,7 @@
namespace Drupal\block;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Plugin\PluginBase;
use Drupal\block\BlockInterface;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Language\Language;
......@@ -91,14 +91,14 @@ public function buildConfigurationForm(array $form, array &$form_state) {
$form['label'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#title' => $this->t('Title'),
'#maxlength' => 255,
'#default_value' => !empty($this->configuration['label']) ? $this->configuration['label'] : $definition['admin_label'],
'#required' => TRUE,
);
$form['label_display'] = array(
'#type' => 'checkbox',
'#title' => t('Display title'),
'#title' => $this->t('Display title'),
'#default_value' => $this->configuration['label_display'] == BlockInterface::BLOCK_LABEL_VISIBLE,
'#return_value' => BlockInterface::BLOCK_LABEL_VISIBLE,
);
......
......@@ -7,7 +7,7 @@
namespace Drupal\ckeditor;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Plugin\PluginBase;
use Drupal\editor\Entity\Editor;
/**
......
......@@ -7,7 +7,7 @@
namespace Drupal\edit;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Plugin\PluginBase;
use Drupal\edit\EditPluginInterface;
use Drupal\Core\Entity\Field\FieldDefinitionInterface;
......
......@@ -7,7 +7,7 @@
namespace Drupal\editor\Plugin;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Plugin\PluginBase;
use Drupal\editor\Entity\Editor;
use Drupal\editor\Plugin\EditorPluginInterface;
......
......@@ -7,7 +7,7 @@
namespace Drupal\field\Plugin;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Plugin\PluginBase;
use Drupal\field\Plugin\PluginSettingsInterface;
/**
......
......@@ -7,7 +7,7 @@
namespace Drupal\filter\Plugin;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Plugin\PluginBase;
/**
* Provides a base class for Filter plugins.
......
......@@ -7,7 +7,7 @@
namespace Drupal\image;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Plugin\PluginBase;
/**
* Provides a base class for image effects.
......
......@@ -7,8 +7,8 @@
namespace Drupal\rest\Plugin;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
......
......@@ -7,7 +7,7 @@
namespace Drupal\search\Plugin;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Plugin\PluginBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
/**
......
......@@ -7,7 +7,7 @@
namespace Drupal\system\Plugin\ImageToolkit;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Plugin\PluginBase;
use Drupal\system\Annotation\ImageToolkit;
use Drupal\Core\Annotation\Translation;
use Drupal\Core\Image\ImageInterface;
......
......@@ -7,7 +7,7 @@
namespace Drupal\image_test\Plugin\ImageToolkit;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Plugin\PluginBase;
use Drupal\system\Annotation\ImageToolkit;
use Drupal\Core\Annotation\Translation;
use Drupal\Core\Image\ImageInterface;
......
......@@ -7,7 +7,7 @@
namespace Drupal\tour;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Plugin\PluginBase;
use Drupal\tour\TipPluginInterface;
/**
......
......@@ -7,8 +7,8 @@
namespace Drupal\views\Plugin\views;
use Drupal\Component\Plugin\PluginBase as ComponentPluginBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginBase as ComponentPluginBase;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable;
use Symfony\Component\DependencyInjection\ContainerInterface;
......
......@@ -7,7 +7,7 @@
namespace Drupal\views\Plugin\views\join;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Plugin\PluginBase;
/**
* @defgroup views_join_handlers Views join handlers
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment