Base class for plugin managers.
Expanded class hierarchy of PluginManagerBase
abstract class PluginManagerBase implements PluginManagerInterface, CachedDiscoveryInterface {
/**
* The object that discovers plugins managed by this manager.
*
* @var \Drupal\Component\Plugin\Discovery\DiscoveryInterface
*/
protected $discovery;
/**
* The object that instantiates plugins managed by this manager.
*
* @var \Drupal\Component\Plugin\Factory\FactoryInterface
*/
protected $factory;
/**
* The object that returns the preconfigured plugin instance appropriate for a particular runtime condition.
*
* @var \Drupal\Component\Plugin\Mapper\MapperInterface
*/
protected $mapper;
/**
* A set of defaults to be referenced by $this->processDefinition() if
* additional processing of plugins is necessary or helpful for development
* purposes.
*
* @var array
*/
protected $defaults = array();
/**
* {@inheritdoc}
*/
public function getDefinition($plugin_id) {
return $this->discovery
->getDefinition($plugin_id);
}
/**
* {@inheritdoc}
*/
public function getDefinitions() {
return $this->discovery
->getDefinitions();
}
/**
* {@inheritdoc}
*/
public function clearCachedDefinitions() {
if ($this->discovery instanceof CachedDiscoveryInterface) {
$this->discovery
->clearCachedDefinitions();
}
}
/**
* {@inheritdoc}
*/
public function createInstance($plugin_id, array $configuration = array()) {
return $this->factory
->createInstance($plugin_id, $configuration);
}
/**
* {@inheritdoc}
*/
public function getInstance(array $options) {
return $this->mapper
->getInstance($options);
}
/**
* Performs extra processing on plugin definitions.
*
* By default we add defaults for the type to the definition. If a type has
* additional processing logic they can do that by replacing or extending the
* method.
*/
public function processDefinition(&$definition, $plugin_id) {
$definition = NestedArray::mergeDeep($this->defaults, $definition);
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PluginManagerBase:: |
protected | property | A set of defaults to be referenced by $this->processDefinition() if additional processing of plugins is necessary or helpful for development purposes. | 3 |
PluginManagerBase:: |
protected | property | The object that discovers plugins managed by this manager. | |
PluginManagerBase:: |
protected | property | The object that instantiates plugins managed by this manager. | |
PluginManagerBase:: |
protected | property | The object that returns the preconfigured plugin instance appropriate for a particular runtime condition. | |
PluginManagerBase:: |
public | function |
Clears static and persistent plugin definition caches. Overrides CachedDiscoveryInterface:: |
|
PluginManagerBase:: |
public | function |
Returns a preconfigured instance of a plugin. Overrides FactoryInterface:: |
6 |
PluginManagerBase:: |
public | function |
Gets a specific plugin definition. Overrides DiscoveryInterface:: |
|
PluginManagerBase:: |
public | function |
Gets the definition of all plugins for this type. Overrides DiscoveryInterface:: |
|
PluginManagerBase:: |
public | function |
Returns a preconfigured instance of a plugin. Overrides MapperInterface:: |
6 |
PluginManagerBase:: |
public | function | Performs extra processing on plugin definitions. | 2 |