protected function MultiSelect2BoxesAutocompleteWidget::getAutocompletePath in Select2 Boxes 8
Get entity autocomplete path.
Return value
\Drupal\Core\GeneratedUrl|string Entity autocomplete path.
1 call to MultiSelect2BoxesAutocompleteWidget::getAutocompletePath()
- MultiSelect2BoxesAutocompleteWidget::formElement in src/
Plugin/ Field/ FieldWidget/ MultiSelect2BoxesAutocompleteWidget.php - Returns the form for a single field widget.
File
- src/
Plugin/ Field/ FieldWidget/ MultiSelect2BoxesAutocompleteWidget.php, line 144
Class
- MultiSelect2BoxesAutocompleteWidget
- Plugin implementation of the 'entity_reference autocomplete-tags' widget.
Namespace
Drupal\select2boxes\Plugin\Field\FieldWidgetCode
protected function getAutocompletePath() {
// Store the selection settings in the key/value store and pass a hashed key
// in the route parameters.
$selection_settings = $this
->getFieldSetting('handler_settings');
$data = serialize($selection_settings) . $this
->getFieldSetting('target_type') . $this
->getFieldSetting('handler');
$selection_settings_key = Crypt::hmacBase64($data, Settings::getHashSalt());
$key_value_storage = \Drupal::keyValue('entity_autocomplete');
if (!$key_value_storage
->has($selection_settings_key)) {
$key_value_storage
->set($selection_settings_key, $selection_settings);
}
$params = [
'target_type' => $this
->getFieldSetting('target_type'),
'selection_handler' => $this
->getFieldSetting('handler'),
'selection_settings_key' => $selection_settings_key,
];
return Url::fromRoute('system.entity_autocomplete', $params)
->toString();
}