function SelectionPluginManager::getInstance
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 35
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 (str_contains($options['handler'], ':')) {
$plugin_id = $options['handler'];
}
else {
$plugin_id = $this->getPluginId($options['target_type'], $options['handler']);
}
unset($options['handler']);
return $this->createInstance($plugin_id, $options);
}