public function SelectionPluginManager::getInstance in Multi-path autocomplete 8
Overrides \Drupal\Component\Plugin\PluginManagerBase::getInstance().
Overrides PluginManagerBase::getInstance
File
- lib/
Drupal/ mpac/ Plugin/ Type/ SelectionPluginManager.php, line 43 - Contains \Drupal\mpac\Plugin\Type\SelectionPluginManager.
Class
- SelectionPluginManager
- Plugin type manager for the Multi-path autocomplete Selection plugin.
Namespace
Drupal\mpac\Plugin\TypeCode
public function getInstance(array $options) {
$type = $options['type'];
// Get all available selection plugins for this entity type.
$selection_handler_groups = $this
->getSelectionGroups($type);
// Sort the selection plugins by weight and select the best match.
uasort($selection_handler_groups, array(
'Drupal\\Component\\Utility\\SortArray',
'sortByWeightElement',
));
end($selection_handler_groups);
$plugin_id = key($selection_handler_groups);
if ($plugin_id) {
return $this
->createInstance($plugin_id, $options);
}
else {
return new SelectionBroken();
}
}