public function SelectionPluginManager::getInstance in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 depends 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 39 - Contains \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManager.
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 += array(
'handler' => $this
->getPluginId($options['target_type'], 'default'),
'handler_settings' => array(),
);
// 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']);
}
return $this
->createInstance($plugin_id, $options);
}