ReflectionFactory
class ReflectionFactory extends DefaultFactory (View source)
A plugin factory that maps instance configuration to constructor arguments.
Provides logic for any basic plugin type that needs to provide individual plugins based upon some basic logic.
Properties
| protected DiscoveryInterface | $discovery | The object that retrieves the definitions of the plugins that this factory instantiates. |
from DefaultFactory |
| protected string|null | $interface | Defines an interface each plugin should implement. |
from DefaultFactory |
Methods
Constructs a Drupal\Component\Plugin\Factory\DefaultFactory object.
Creates a pre-configured instance of a plugin.
Finds the class relevant for a given plugin.
Inspects the plugin class and build a list of arguments for the constructor.
Details
__construct(DiscoveryInterface $discovery, string|null $plugin_interface = NULL)
Constructs a Drupal\Component\Plugin\Factory\DefaultFactory object.
object
createInstance(string $plugin_id, array $configuration = [])
Creates a pre-configured instance of a plugin.
static string
getPluginClass(string $plugin_id, PluginDefinitionInterface|array $plugin_definition = NULL, string $required_interface = NULL)
Finds the class relevant for a given plugin.
protected array
getInstanceArguments(ReflectionClass $reflector, string $plugin_id, mixed $plugin_definition, array $configuration)
Inspects the plugin class and build a list of arguments for the constructor.
This is provided as a helper method so factories extending this class can replace this and insert their own reflection logic.