abstract class ConfigurablePluginBase in Search API 8
Provides a base class for all configurable Search API plugins.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\search_api\Plugin\HideablePluginBase implements HideablePluginInterface
- class \Drupal\search_api\Plugin\ConfigurablePluginBase implements ConfigurablePluginInterface uses PluginDependencyTrait
- class \Drupal\search_api\Plugin\HideablePluginBase implements HideablePluginInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of ConfigurablePluginBase
1 file declares its use of ConfigurablePluginBase
- BackendPluginBase.php in src/
Backend/ BackendPluginBase.php
File
- src/
Plugin/ ConfigurablePluginBase.php, line 12
Namespace
Drupal\search_api\PluginView source
abstract class ConfigurablePluginBase extends HideablePluginBase implements ConfigurablePluginInterface {
// Normally, we'd just need \Drupal\Core\Entity\DependencyTrait here for
// plugins. However, in a few cases, plugins use plugins themselves, and then
// the additional calculatePluginDependencies() method from this trait is
// useful. Since PHP 5 complains when adding this trait along with its
// "parent" trait to the same class, we just add it here in case a child class
// does need it.
use PluginDependencyTrait {
getPluginDependencies as traitGetPluginDependencies;
calculatePluginDependencies as traitCalculatePluginDependencies;
moduleHandler as traitModuleHandler;
themeHandler as traitThemeHandler;
}
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, array $plugin_definition) {
$configuration += $this
->defaultConfiguration();
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
$plugin = new static($configuration, $plugin_id, $plugin_definition);
/** @var \Drupal\Core\StringTranslation\TranslationInterface $translation */
$translation = $container
->get('string_translation');
$plugin
->setStringTranslation($translation);
return $plugin;
}
/**
* {@inheritdoc}
*/
public function label() {
$plugin_definition = $this
->getPluginDefinition();
return $plugin_definition['label'];
}
/**
* {@inheritdoc}
*/
public function getDescription() {
$plugin_definition = $this
->getPluginDefinition();
return $plugin_definition['description'] ?? '';
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [];
}
/**
* {@inheritdoc}
*/
public function getConfiguration() {
return $this->configuration;
}
/**
* {@inheritdoc}
*/
public function setConfiguration(array $configuration) {
$this->configuration = $configuration + $this
->defaultConfiguration();
}
/**
* {@inheritdoc}
*/
public function calculateDependencies() {
return [];
}
/**
* {@inheritdoc}
*/
public function onDependencyRemoval(array $dependencies) {
// By default, we're not reacting to anything and so we should leave
// everything as it was.
return FALSE;
}
/**
* Calculates and returns dependencies of a specific plugin instance.
*
* Dependencies are added for the module that provides the plugin, as well
* as any dependencies declared by the instance's calculateDependencies()
* method, if it implements
* \Drupal\Component\Plugin\DependentPluginInterface.
*
* @param \Drupal\Component\Plugin\PluginInspectionInterface $instance
* The plugin instance.
*
* @return array
* An array of dependencies keyed by the type of dependency.
*
* @deprecated in search_api:8.x-1.16 and is removed from search_api:2.0.0.
* Add \Drupal\Core\Plugin\PluginDependencyTrait manually for your class if
* you need it.
*
* @see https://www.drupal.org/node/3099004
*/
protected function getPluginDependencies(PluginInspectionInterface $instance) {
@trigger_error('The use of \\Drupal\\Core\\Plugin\\PluginDependencyTrait via \\Drupal\\search_api\\Plugin\\ConfigurablePluginBase is deprecated in search_api:8.x-1.16 and is removed from search_api:2.0.0. Add \\Drupal\\Core\\Plugin\\PluginDependencyTrait manually for your class if you need it. See https://www.drupal.org/node/3099004', E_USER_DEPRECATED);
return $this
->traitGetPluginDependencies($instance);
}
/**
* Calculates and adds dependencies of a specific plugin instance.
*
* Dependencies are added for the module that provides the plugin, as well
* as any dependencies declared by the instance's calculateDependencies()
* method, if it implements
* \Drupal\Component\Plugin\DependentPluginInterface.
*
* @param \Drupal\Component\Plugin\PluginInspectionInterface $instance
* The plugin instance.
*
* @deprecated in search_api:8.x-1.16 and is removed from search_api:2.0.0.
* Add \Drupal\Core\Plugin\PluginDependencyTrait manually for your class if
* you need it.
*
* @see https://www.drupal.org/node/3099004
*/
protected function calculatePluginDependencies(PluginInspectionInterface $instance) {
@trigger_error('The use of \\Drupal\\Core\\Plugin\\PluginDependencyTrait via \\Drupal\\search_api\\Plugin\\ConfigurablePluginBase is deprecated in search_api:8.x-1.16 and is removed from search_api:2.0.0. Add \\Drupal\\Core\\Plugin\\PluginDependencyTrait manually for your class if you need it. See https://www.drupal.org/node/3099004', E_USER_DEPRECATED);
$this
->traitCalculatePluginDependencies($instance);
}
/**
* Wraps the module handler.
*
* @return \Drupal\Core\Extension\ModuleHandlerInterface
* The module handler.
*
* @deprecated in search_api:8.x-1.16 and is removed from search_api:2.0.0.
* Add \Drupal\Core\Plugin\PluginDependencyTrait manually for your class if
* you need it.
*
* @see https://www.drupal.org/node/3099004
*/
protected function moduleHandler() {
@trigger_error('The use of \\Drupal\\Core\\Plugin\\PluginDependencyTrait via \\Drupal\\search_api\\Plugin\\ConfigurablePluginBase is deprecated in search_api:8.x-1.16 and is removed from search_api:2.0.0. Add \\Drupal\\Core\\Plugin\\PluginDependencyTrait manually for your class if you need it. See https://www.drupal.org/node/3099004', E_USER_DEPRECATED);
return $this
->traitModuleHandler();
}
/**
* Wraps the theme handler.
*
* @return \Drupal\Core\Extension\ThemeHandlerInterface
* The theme handler.
*
* @deprecated in search_api:8.x-1.16 and is removed from search_api:2.0.0.
* Add \Drupal\Core\Plugin\PluginDependencyTrait manually for your class if
* you need it.
*
* @see https://www.drupal.org/node/3099004
*/
protected function themeHandler() {
@trigger_error('The use of \\Drupal\\Core\\Plugin\\PluginDependencyTrait via \\Drupal\\search_api\\Plugin\\ConfigurablePluginBase is deprecated in search_api:8.x-1.16 and is removed from search_api:2.0.0. Add \\Drupal\\Core\\Plugin\\PluginDependencyTrait manually for your class if you need it. See https://www.drupal.org/node/3099004', E_USER_DEPRECATED);
return $this
->traitThemeHandler();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigurablePluginBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
6 |
ConfigurablePluginBase:: |
protected | function | Calculates and adds dependencies of a specific plugin instance. | |
ConfigurablePluginBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
4 |
ConfigurablePluginBase:: |
public | function |
Gets default configuration for this plugin. Overrides ConfigurableInterface:: |
11 |
ConfigurablePluginBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
ConfigurablePluginBase:: |
public | function |
Returns the plugin's description. Overrides ConfigurablePluginInterface:: |
|
ConfigurablePluginBase:: |
protected | function | Calculates and returns dependencies of a specific plugin instance. | |
ConfigurablePluginBase:: |
public | function |
Returns the label for use on the administration pages. Overrides ConfigurablePluginInterface:: |
|
ConfigurablePluginBase:: |
protected | function | Wraps the module handler. | |
ConfigurablePluginBase:: |
public | function |
Informs the plugin that some of its dependencies are being removed. Overrides ConfigurablePluginInterface:: |
5 |
ConfigurablePluginBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
3 |
ConfigurablePluginBase:: |
protected | function | Wraps the theme handler. | |
ConfigurablePluginBase:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
2 |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
DependencyTrait:: |
protected | property | The object's dependencies. | |
DependencyTrait:: |
protected | function | Adds multiple dependencies. | |
DependencyTrait:: |
protected | function | Adds a dependency. | |
HideablePluginBase:: |
public | function |
Determines whether this plugin should be hidden in the UI. Overrides HideablePluginInterface:: |
1 |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
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:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginDependencyTrait:: |
protected | function | Calculates and adds dependencies of a specific plugin instance. Aliased as: traitCalculatePluginDependencies | 1 |
PluginDependencyTrait:: |
protected | function | Calculates and returns dependencies of a specific plugin instance. Aliased as: traitGetPluginDependencies | |
PluginDependencyTrait:: |
protected | function | Wraps the module handler. Aliased as: traitModuleHandler | 1 |
PluginDependencyTrait:: |
protected | function | Wraps the theme handler. Aliased as: traitThemeHandler | 1 |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
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. |