class DefaultsTestPluginManager
Same name and namespace in other branches
- 11.x core/modules/system/tests/modules/plugin_test/src/Plugin/DefaultsTestPluginManager.php \Drupal\plugin_test\Plugin\DefaultsTestPluginManager
- 10 core/modules/system/tests/modules/plugin_test/src/Plugin/DefaultsTestPluginManager.php \Drupal\plugin_test\Plugin\DefaultsTestPluginManager
- 8.9.x core/modules/system/tests/modules/plugin_test/src/Plugin/DefaultsTestPluginManager.php \Drupal\plugin_test\Plugin\DefaultsTestPluginManager
Defines a plugin manager used by Plugin API unit tests.
Hierarchy
- class \Drupal\Component\Plugin\PluginManagerBase implements \Drupal\Component\Plugin\PluginManagerInterface uses \Drupal\Component\Plugin\Discovery\DiscoveryTrait
- class \Drupal\Core\Plugin\DefaultPluginManager implements \Drupal\Component\Plugin\PluginManagerInterface, \Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface, \Drupal\Core\Cache\CacheableDependencyInterface uses \Drupal\Component\Plugin\Discovery\DiscoveryCachedTrait, \Drupal\Core\Cache\UseCacheBackendTrait extends \Drupal\Component\Plugin\PluginManagerBase
- class \Drupal\plugin_test\Plugin\DefaultsTestPluginManager extends \Drupal\Core\Plugin\DefaultPluginManager
- class \Drupal\Core\Plugin\DefaultPluginManager implements \Drupal\Component\Plugin\PluginManagerInterface, \Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface, \Drupal\Core\Cache\CacheableDependencyInterface uses \Drupal\Component\Plugin\Discovery\DiscoveryCachedTrait, \Drupal\Core\Cache\UseCacheBackendTrait extends \Drupal\Component\Plugin\PluginManagerBase
Expanded class hierarchy of DefaultsTestPluginManager
1 file declares its use of DefaultsTestPluginManager
- PluginTestBase.php in core/
tests/ Drupal/ KernelTests/ Core/ Plugin/ PluginTestBase.php
File
-
core/
modules/ system/ tests/ modules/ plugin_test/ src/ Plugin/ DefaultsTestPluginManager.php, line 13
Namespace
Drupal\plugin_test\PluginView source
class DefaultsTestPluginManager extends DefaultPluginManager {
/**
* Constructs a new DefaultsTestPluginManager instance.
*
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
*/
public function __construct(ModuleHandlerInterface $module_handler) {
// 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->factory = new DefaultFactory($this, 'Drupal\\Component\\Plugin\\PluginInspectionInterface');
$this->moduleHandler = $module_handler;
// Specify default values.
$this->defaults = [
'metadata' => [
'default' => TRUE,
],
];
// Add a plugin with a custom value.
$this->discovery
->setDefinition('test_block1', [
'class' => 'Drupal\\plugin_test\\Plugin\\plugin_test\\mock_block\\MockTestBlock',
'metadata' => [
'custom' => TRUE,
],
]);
// Add a plugin that overrides the default value.
$this->discovery
->setDefinition('test_block2', [
'class' => 'Drupal\\plugin_test\\Plugin\\plugin_test\\mock_block\\MockTestBlock',
'metadata' => [
'custom' => TRUE,
'default' => FALSE,
],
]);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.