class ConfigAutocompleteController in Monitoring 8
Returns auto complete responses for config.
Hierarchy
- class \Drupal\monitoring\Controller\ConfigAutocompleteController
Expanded class hierarchy of ConfigAutocompleteController
File
- src/
Controller/ ConfigAutocompleteController.php, line 17 - Contains \Drupal\monitoring\Controller\ConfigAutocompleteController.
Namespace
Drupal\monitoring\ControllerView source
class ConfigAutocompleteController {
/**
* Retrieves suggestions for config auto completion.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request.
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
* A JSON response containing autocomplete suggestions.
*/
public function autocomplete(Request $request) {
$matches = array();
$prefixMatches = array_slice(\Drupal::service('config.factory')
->listAll($request->query
->get('q')), 0, 10);
foreach ($prefixMatches as $config) {
$matches[] = array(
'value' => $config,
'label' => new HtmlEscapedText($config),
);
}
return new JsonResponse($matches);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigAutocompleteController:: |
public | function | Retrieves suggestions for config auto completion. |