Implements Drupal\Component\Plugin\Factory\FactoryInterface::createInstance().
Overrides DefaultFactory::createInstance
public function createInstance($plugin_id, array $configuration) {
$plugin_class = $this
->getPluginClass($plugin_id);
// Lets figure out of there's a constructor for this class and pull
// arguments from the $options array if so to populate it.
$reflector = new ReflectionClass($plugin_class);
if ($reflector
->hasMethod('__construct')) {
$arguments = $this
->getInstanceArguments($reflector, $plugin_id, $configuration);
$instance = $reflector
->newInstanceArgs($arguments);
}
else {
$instance = new $plugin_class();
}
return $instance;
}