class MockManager in Plugin 8.2
Provides a plugin manager for testing plugin-related functionality.
Configuration schemas for this manager's plugins are named "plugin_test_helper.plugin_configuration.plugin_test_helper_mock.[plugin_id]", where "[plugin_id]" is the ID of the plugin the schema is for.
Hierarchy
- class \Drupal\Component\Plugin\PluginManagerBase implements PluginManagerInterface uses DiscoveryTrait
- class \Drupal\plugin_test_helper\Plugin\PluginTestHelper\MockManager implements TypedDiscoveryInterface
Expanded class hierarchy of MockManager
1 file declares its use of MockManager
- PluginCollectionItemBaseTest.php in tests/
src/ Kernel/ Plugin/ Field/ FieldType/ PluginCollectionItemBaseTest.php
1 string reference to 'MockManager'
- plugin_test_helper.services.yml in tests/
modules/ plugin_test_helper/ plugin_test_helper.services.yml - tests/modules/plugin_test_helper/plugin_test_helper.services.yml
1 service uses MockManager
- plugin.manager.plugin_test_helper.mock in tests/
modules/ plugin_test_helper/ plugin_test_helper.services.yml - Drupal\plugin_test_helper\Plugin\PluginTestHelper\MockManager
File
- tests/
modules/ plugin_test_helper/ src/ Plugin/ PluginTestHelper/ MockManager.php, line 18
Namespace
Drupal\plugin_test_helper\Plugin\PluginTestHelperView source
class MockManager extends PluginManagerBase implements TypedDiscoveryInterface {
/**
* Constructs a new instance.
*/
public function __construct() {
$this->discovery = new StaticDiscovery();
$plugin_id = 'plugin_test_helper_plugin';
$this->discovery
->setDefinition($plugin_id, new ArrayPluginDefinitionDecorator([
'id' => $plugin_id,
'label' => t('Plugin'),
'class' => MockPlugin::class,
]));
$configurable_plugin_id = 'plugin_test_helper_configurable_plugin';
$this->discovery
->setDefinition($configurable_plugin_id, new ArrayPluginDefinitionDecorator([
'id' => $configurable_plugin_id,
'label' => t('Configurable plugin'),
'class' => MockConfigurablePlugin::class,
]));
$this->factory = new DefaultFactory($this->discovery);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DiscoveryTrait:: |
protected | function | Gets a specific plugin definition. | |
DiscoveryTrait:: |
public | function | ||
MockManager:: |
public | function | Constructs a new instance. | |
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 |
Creates a pre-configured instance of a plugin. Overrides FactoryInterface:: |
12 |
PluginManagerBase:: |
public | function |
Gets a specific plugin definition. Overrides DiscoveryTrait:: |
|
PluginManagerBase:: |
public | function |
Gets the definition of all plugins for this type. Overrides DiscoveryTrait:: |
|
PluginManagerBase:: |
protected | function | Gets the plugin discovery. | 1 |
PluginManagerBase:: |
protected | function | Gets the plugin factory. | 1 |
PluginManagerBase:: |
public | function |
Gets a preconfigured instance of a plugin. Overrides MapperInterface:: |
7 |
PluginManagerBase:: |
protected | function | Allows plugin managers to specify custom behavior if a plugin is not found. | 1 |