abstract class StylesGroupPluginBase in Bootstrap Styles 1.0.x
A base class to help developers implement their own Styles Group plugins.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\bootstrap_styles\StylesGroup\StylesGroupPluginBase implements StylesGroupPluginInterface, ContainerFactoryPluginInterface uses StringTranslationTrait
Expanded class hierarchy of StylesGroupPluginBase
6 files declare their use of StylesGroupPluginBase
- Animation.php in src/
Plugin/ BootstrapStyles/ StylesGroup/ Animation.php - Background.php in src/
Plugin/ BootstrapStyles/ StylesGroup/ Background.php - Border.php in src/
Plugin/ BootstrapStyles/ StylesGroup/ Border.php - Shadow.php in src/
Plugin/ BootstrapStyles/ StylesGroup/ Shadow.php - Spacing.php in src/
Plugin/ BootstrapStyles/ StylesGroup/ Spacing.php
File
- src/
StylesGroup/ StylesGroupPluginBase.php, line 16
Namespace
Drupal\bootstrap_styles\StylesGroupView source
abstract class StylesGroupPluginBase extends PluginBase implements StylesGroupPluginInterface, ContainerFactoryPluginInterface {
use StringTranslationTrait, HelperTrait;
/**
* Config settings.
*
* @var string
*/
const CONFIG = 'bootstrap_styles.settings';
/**
* The config factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* Constructs a StylePluginBase object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin ID for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The configuration factory.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->configFactory = $config_factory;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('config.factory'));
}
/**
* {@inheritdoc}
*/
public function getTitle() {
return $this->pluginDefinition['title'];
}
/**
* {@inheritdoc}
*/
public function getIconPath() {
// The default icon.
$icon_path = drupal_get_path('module', 'bootstrap_styles') . 'images/plugin-group-default-icon.svg';
if (isset($this->pluginDefinition['icon'])) {
$icon = $this->pluginDefinition['icon'];
$path_array = explode('/', $icon);
if (isset($path_array[0])) {
$module_name = $path_array[0];
$icon_path = drupal_get_path('module', $module_name) . str_replace($module_name, '', $icon);
}
}
return $icon_path;
}
/**
* {@inheritdoc}
*/
public function getTitleWithIcon() {
return [
'#markup' => $this
->getSvgIconMarkup($this
->getIconPath()),
'#prefix' => '<span class="bs-group-title">',
'#suffix' => $this
->getTitle() . '</span>',
];
}
/**
* {@inheritdoc}
*/
public function config() {
return $this->configFactory
->getEditable(static::CONFIG);
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
return $form;
}
/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
}
/**
* {@inheritdoc}
*/
public function buildStyleFormElements(array &$form, FormStateInterface $form_state, $storage) {
return [];
}
/**
* {@inheritdoc}
*/
public function submitStyleFormElements(array $group_elements) {
return [];
}
/**
* {@inheritdoc}
*/
public function build(array $build, array $storage, $theme_wrapper = NULL) {
return $build;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
2 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
StylesGroupPluginBase:: |
protected | property | The config factory. | |
StylesGroupPluginBase:: |
public | function | ||
StylesGroupPluginBase:: |
public | function | 6 | |
StylesGroupPluginBase:: |
public | function | 5 | |
StylesGroupPluginBase:: |
public | function | ||
StylesGroupPluginBase:: |
constant | Config settings. | ||
StylesGroupPluginBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
StylesGroupPluginBase:: |
public | function | ||
StylesGroupPluginBase:: |
public | function |
Return the title of the Styles Group form plugin. Overrides StylesGroupPluginInterface:: |
|
StylesGroupPluginBase:: |
public | function | ||
StylesGroupPluginBase:: |
public | function | ||
StylesGroupPluginBase:: |
public | function | 1 | |
StylesGroupPluginBase:: |
public | function | ||
StylesGroupPluginBase:: |
public | function |
Constructs a StylePluginBase object. Overrides PluginBase:: |