class StubReflectionFactory in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php \Drupal\Tests\Component\Plugin\Factory\StubReflectionFactory
Override ReflectionFactory because ::createInstance() calls a static method.
We have to override getPluginClass so that we can stub out its return value.
Hierarchy
- class \Drupal\Component\Plugin\Factory\DefaultFactory implements FactoryInterface
- class \Drupal\Component\Plugin\Factory\ReflectionFactory
- class \Drupal\Tests\Component\Plugin\Factory\StubReflectionFactory
- class \Drupal\Component\Plugin\Factory\ReflectionFactory
Expanded class hierarchy of StubReflectionFactory
File
- core/
tests/ Drupal/ Tests/ Component/ Plugin/ Factory/ ReflectionFactoryTest.php, line 143 - Contains \Drupal\Tests\Component\Plugin\Factory\ReflectionFactoryTest.
Namespace
Drupal\Tests\Component\Plugin\FactoryView source
class StubReflectionFactory extends ReflectionFactory {
/**
* {@inheritdoc}
*/
public static function getPluginClass($plugin_id, $plugin_definition = NULL, $required_interface = NULL) {
// Return the class name from the plugin definition.
return $plugin_definition[$plugin_id]['class'];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DefaultFactory:: |
protected | property | The object that retrieves the definitions of the plugins that this factory instantiates. | |
DefaultFactory:: |
protected | property | Defines an interface each plugin should implement. | |
DefaultFactory:: |
public | function | Constructs a Drupal\Component\Plugin\Factory\DefaultFactory object. | |
ReflectionFactory:: |
public | function |
Creates a pre-configured instance of a plugin. Overrides DefaultFactory:: |
|
ReflectionFactory:: |
protected | function | Inspects the plugin class and build a list of arguments for the constructor. | |
StubReflectionFactory:: |
public static | function |
Finds the class relevant for a given plugin. Overrides DefaultFactory:: |