Initializes a plugin and stores the result in $this->pluginInstances.
string $instance_id: The ID of the plugin instance to initialize.
Overrides PluginBag::initializePlugin
protected function initializePlugin($instance_id) {
// If the filter was initialized before, just return.
if (isset($this->pluginInstances[$instance_id])) {
return;
}
// Filters have a 1:1 relationship to text formats and can be added and
// instantiated at any time.
$definition = $this->manager
->getDefinition($instance_id);
if (isset($definition)) {
$this
->addInstanceID($instance_id);
// $configuration is the whole filter plugin instance configuration, as
// contained in the text format configuration. The default configuration
// is the filter plugin definition.
// @todo Configuration should not be contained in definitions. Move into a
// FilterBase::init() method.
$configuration = $definition;
// Merge the actual configuration into the default configuration.
if (isset($this->configurations[$instance_id])) {
$configuration = NestedArray::mergeDeep($configuration, $this->configurations[$instance_id]);
}
$this->pluginInstances[$instance_id] = $this->manager
->createInstance($instance_id, $configuration, $this);
}
else {
throw new PluginException(format_string("Unknown filter plugin ID '@filter'.", array(
'@filter' => $instance_id,
)));
}
}