function FormatterPluginManager::createInstance
Same name in other branches
- 9 core/lib/Drupal/Core/Field/FormatterPluginManager.php \Drupal\Core\Field\FormatterPluginManager::createInstance()
- 8.9.x core/lib/Drupal/Core/Field/FormatterPluginManager.php \Drupal\Core\Field\FormatterPluginManager::createInstance()
- 10 core/lib/Drupal/Core/Field/FormatterPluginManager.php \Drupal\Core\Field\FormatterPluginManager::createInstance()
Overrides PluginManagerBase::createInstance
1 call to FormatterPluginManager::createInstance()
- FormatterPluginManager::getInstance in core/
lib/ Drupal/ Core/ Field/ FormatterPluginManager.php - Overrides PluginManagerBase::getInstance().
File
-
core/
lib/ Drupal/ Core/ Field/ FormatterPluginManager.php, line 56
Class
- FormatterPluginManager
- Plugin type manager for field formatters.
Namespace
Drupal\Core\FieldCode
public function createInstance($plugin_id, array $configuration = []) {
$plugin_definition = $this->getDefinition($plugin_id);
$plugin_class = DefaultFactory::getPluginClass($plugin_id, $plugin_definition);
// @todo This is copied from \Drupal\Core\Plugin\Factory\ContainerFactory.
// Find a way to restore sanity to
// \Drupal\Core\Field\FormatterBase::__construct().
// If the plugin provides a factory method, pass the container to it.
if (is_subclass_of($plugin_class, 'Drupal\\Core\\Plugin\\ContainerFactoryPluginInterface')) {
return $plugin_class::create(\Drupal::getContainer(), $configuration, $plugin_id, $plugin_definition);
}
return new $plugin_class($plugin_id, $plugin_definition, $configuration['field_definition'], $configuration['settings'], $configuration['label'], $configuration['view_mode'], $configuration['third_party_settings']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.