public function TfaSetupPluginManager::createInstance in Two-factor Authentication (TFA) 8
Create an instance of a setup plugin.
Parameters
string $plugin_id: The id of the setup plugin.
array $configuration: Configuration data for the setup plugin.
Return value
object Require setup plugin instance
Throws
\Drupal\Component\Plugin\Exception\PluginNotFoundException
\Drupal\Component\Plugin\Exception\PluginException
Overrides PluginManagerBase::createInstance
File
- src/
TfaSetupPluginManager.php, line 79
Class
- TfaSetupPluginManager
- The setup plugin manager.
Namespace
Drupal\tfaCode
public function createInstance($plugin_id, array $configuration = []) {
$plugin_definition = $this
->getDefinition($plugin_id);
$plugin_class = DefaultFactory::getPluginClass($plugin_id, $plugin_definition);
// If the plugin provides a factory method, pass the container to it.
if (is_subclass_of($plugin_class, 'Drupal\\Core\\Plugin\\ContainerFactoryPluginInterface')) {
// phpcs:ignore DrupalPractice.Objects.GlobalDrupal.GlobalDrupal
$plugin = $plugin_class::create(\Drupal::getContainer(), $configuration, $plugin_id, $plugin_definition, $this->userData, $this->encryptionProfileManager, $this->encryptService);
}
else {
$plugin = new $plugin_class($configuration, $plugin_id, $plugin_definition, $this->userData, $this->encryptionProfileManager, $this->encryptService);
}
return $plugin;
}