public function AutocompleteController::autocomplete in Salesforce Suite 8.3
Autocomplete.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The request object providing the autocomplete query parameter.
string $entity_type_id: The entity type filter options by.
string $bundle: The bundle of the entity to filter options by.
Return value
\Symfony\Component\HttpFoundation\JsonResponse The JSON results.
1 string reference to 'AutocompleteController::autocomplete'
- salesforce_mapping.routing.yml in modules/
salesforce_mapping/ salesforce_mapping.routing.yml - modules/salesforce_mapping/salesforce_mapping.routing.yml
File
- modules/
salesforce_mapping/ src/ Controller/ AutocompleteController.php, line 56
Class
- AutocompleteController
- Class AutocompleteController.
Namespace
Drupal\salesforce_mapping\ControllerCode
public function autocomplete(Request $request, $entity_type_id, $bundle) {
$string = Html::escape(mb_strtolower($request->query
->get('q')));
$field_definitions = $this->fieldManager
->getFieldDefinitions($entity_type_id, $bundle);
// Filter out EntityReference Items.
foreach ($field_definitions as $index => $field_definition) {
if ($field_definition
->getType() === 'entity_reference') {
unset($field_definitions[$index]);
}
}
$results = $this
->getDataFetcher()
->autocompletePropertyPath($field_definitions, $string);
return new JsonResponse($results);
}