public function PluginManagerBase::createInstance in Plug 7
Creates a pre-configured instance of a plugin.
Parameters
string $plugin_id: The ID of the plugin being instantiated.
array $configuration: An array of configuration relevant to the plugin instance.
Return value
object A fully configured plugin instance.
Throws
\Drupal\Component\Plugin\Exception\PluginException If the instance cannot be created, such as if the ID is invalid.
Overrides FactoryInterface::createInstance
File
- lib/
Drupal/ Component/ Plugin/ PluginManagerBase.php, line 76 - Contains \Drupal\Component\Plugin\PluginManagerBase.
Class
- PluginManagerBase
- Base class for plugin managers.
Namespace
Drupal\Component\PluginCode
public function createInstance($plugin_id, array $configuration = array()) {
// If this PluginManager has fallback capabilities catch
// PluginNotFoundExceptions.
if ($this instanceof FallbackPluginManagerInterface) {
try {
return $this
->getFactory()
->createInstance($plugin_id, $configuration);
} catch (PluginNotFoundException $e) {
$fallback_id = $this
->getFallbackPluginId($plugin_id, $configuration);
return $this
->getFactory()
->createInstance($fallback_id, $configuration);
}
}
else {
return $this
->getFactory()
->createInstance($plugin_id, $configuration);
}
}