PluginBase.php in Drupal 8
File
core/lib/Drupal/Component/Plugin/PluginBase.php
View source
<?php
namespace Drupal\Component\Plugin;
abstract class PluginBase implements PluginInspectionInterface, DerivativeInspectionInterface {
const DERIVATIVE_SEPARATOR = ':';
protected $pluginId;
protected $pluginDefinition;
protected $configuration;
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
$this->configuration = $configuration;
$this->pluginId = $plugin_id;
$this->pluginDefinition = $plugin_definition;
if ($this instanceof ConfigurablePluginInterface && !$this instanceof ConfigurableInterface) {
@trigger_error('Drupal\\Component\\Plugin\\ConfigurablePluginInterface is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. You should implement ConfigurableInterface and/or DependentPluginInterface directly as needed. If you implement ConfigurableInterface you may choose to implement ConfigurablePluginInterface in Drupal 8 as well for maximum compatibility, however this must be removed prior to Drupal 9. See https://www.drupal.org/node/2946161', E_USER_DEPRECATED);
}
}
public function getPluginId() {
return $this->pluginId;
}
public function getBaseId() {
$plugin_id = $this
->getPluginId();
if (strpos($plugin_id, static::DERIVATIVE_SEPARATOR)) {
list($plugin_id) = explode(static::DERIVATIVE_SEPARATOR, $plugin_id, 2);
}
return $plugin_id;
}
public function getDerivativeId() {
$plugin_id = $this
->getPluginId();
$derivative_id = NULL;
if (strpos($plugin_id, static::DERIVATIVE_SEPARATOR)) {
list(, $derivative_id) = explode(static::DERIVATIVE_SEPARATOR, $plugin_id, 2);
}
return $derivative_id;
}
public function getPluginDefinition() {
return $this->pluginDefinition;
}
public function isConfigurable() {
return $this instanceof ConfigurableInterface || $this instanceof ConfigurablePluginInterface;
}
}
Classes
Name |
Description |
PluginBase |
Base class for plugins wishing to support metadata inspection. |