Defines a plugin manager used by Plugin API unit tests.
Expanded class hierarchy of DefaultsTestPluginManager
class DefaultsTestPluginManager extends PluginManagerBase {
public function __construct() {
// Create the object that can be used to return definitions for all the
// plugins available for this type. Most real plugin managers use a richer
// discovery implementation, but StaticDiscovery lets us add some simple
// mock plugins for unit testing.
$this->discovery = new StaticDiscovery();
$this->discovery = new ProcessDecorator($this->discovery, array(
$this,
'ProcessDefinition',
));
$this->factory = new DefaultFactory($this->discovery);
// Specify default values.
$this->defaults = array(
'metadata' => array(
'default' => TRUE,
),
);
// Add a plugin with a custom value.
$this->discovery
->setDefinition('test_block1', array(
'class' => 'Drupal\\plugin_test\\Plugin\\plugin_test\\mock_block\\MockTestBlock',
'metadata' => array(
'custom' => TRUE,
),
));
// Add a plugin that overrides the default value.
$this->discovery
->setDefinition('test_block2', array(
'class' => 'Drupal\\plugin_test\\Plugin\\plugin_test\\mock_block\\MockTestBlock',
'metadata' => array(
'custom' => TRUE,
'default' => FALSE,
),
));
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DefaultsTestPluginManager:: |
public | function | ||
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 |