You are here

class ConfigAutocompleteController in Monitoring 8

Returns auto complete responses for config.

Hierarchy

Expanded class hierarchy of ConfigAutocompleteController

File

src/Controller/ConfigAutocompleteController.php, line 17
Contains \Drupal\monitoring\Controller\ConfigAutocompleteController.

Namespace

Drupal\monitoring\Controller
View 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

Namesort descending Modifiers Type Description Overrides
ConfigAutocompleteController::autocomplete public function Retrieves suggestions for config auto completion.