Base class for plugins wishing to support metadata inspection.
Expanded class hierarchy of PluginBase
abstract class PluginBase implements PluginInspectionInterface {
/**
* The discovery object.
*
* @var Drupal\Component\Plugin\Discovery\DiscoveryInterface
*/
protected $discovery;
/**
* The plugin_id.
*
* @var string
*/
protected $plugin_id;
/**
* Configuration information passed into the plugin.
*
* @var array
*/
protected $configuration;
/**
* Constructs a Drupal\Component\Plugin\PluginBase 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 DiscoveryInterface $discovery
* The Discovery class that holds access to the plugin implementation
* definition.
*/
public function __construct(array $configuration, $plugin_id, DiscoveryInterface $discovery) {
$this->configuration = $configuration;
$this->plugin_id = $plugin_id;
$this->discovery = $discovery;
}
/**
* Implements Drupal\Component\Plugin\PluginInterface::getPluginId().
*/
public function getPluginId() {
return $this->plugin_id;
}
/**
* Implements Drupal\Component\Plugin\PluginInterface::getDefinition().
*/
public function getDefinition() {
return $this->discovery
->getDefinition($this->plugin_id);
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The discovery object. | |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
public | function |
Implements Drupal\Component\Plugin\PluginInterface::getDefinition(). Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function |
Implements Drupal\Component\Plugin\PluginInterface::getPluginId(). Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Constructs a Drupal\Component\Plugin\PluginBase object. | 8 |