public function SelectionPluginManager::getInstance in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginManager.php \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManager::getInstance()
- 10 core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginManager.php \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManager::getInstance()
Gets a preconfigured instance of a plugin.
Parameters
array $options: An array of options that can be used to determine a suitable plugin to instantiate and how to configure it.
Return value
object|false A fully configured plugin instance. The interface of the plugin instance will depend on the plugin type. If no instance can be retrieved, FALSE will be returned.
Overrides PluginManagerBase::getInstance
1 call to SelectionPluginManager::getInstance()
- SelectionPluginManager::getSelectionHandler in core/
lib/ Drupal/ Core/ Entity/ EntityReferenceSelection/ SelectionPluginManager.php - Gets the selection handler for a given entity_reference field.
File
- core/
lib/ Drupal/ Core/ Entity/ EntityReferenceSelection/ SelectionPluginManager.php, line 34
Class
- SelectionPluginManager
- Plugin type manager for Entity Reference Selection plugins.
Namespace
Drupal\Core\Entity\EntityReferenceSelectionCode
public function getInstance(array $options) {
if (!isset($options['target_type'])) {
throw new \InvalidArgumentException("Missing required 'target_type' property for a EntityReferenceSelection plugin.");
}
// Initialize default options.
$options += [
'handler' => $this
->getPluginId($options['target_type'], 'default'),
];
// A specific selection plugin ID was already specified.
if (strpos($options['handler'], ':') !== FALSE) {
$plugin_id = $options['handler'];
}
else {
$plugin_id = $this
->getPluginId($options['target_type'], $options['handler']);
}
unset($options['handler']);
return $this
->createInstance($plugin_id, $options);
}