You are here

public function MaestroAutoCompleteController::autocompleteInteractiveHandlers in Maestro 8.2

Same name and namespace in other branches
  1. 3.x src/Controller/MaestroAutoCompleteController.php \Drupal\maestro\Controller\MaestroAutoCompleteController::autocompleteInteractiveHandlers()

Returns response for the autocompletion.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The current request object containing the search string.

Return value

\Symfony\Component\HttpFoundation\JsonResponse A JSON response containing the autocomplete suggestions.

1 string reference to 'MaestroAutoCompleteController::autocompleteInteractiveHandlers'
maestro.routing.yml in ./maestro.routing.yml
maestro.routing.yml

File

src/Controller/MaestroAutoCompleteController.php, line 46

Class

MaestroAutoCompleteController
Maestro Autocomplete controller for roles, interactive handlers and batch handlers.

Namespace

Drupal\maestro\Controller

Code

public function autocompleteInteractiveHandlers(Request $request) {
  $handlers = [];
  $matches = [];
  $string = $request->query
    ->get('q');

  // Let modules signal the handlers they wish to share.
  $handlers = \Drupal::moduleHandler()
    ->invokeAll('maestro_interactive_handlers', []);

  // Now what are our matches based on the incoming request.
  foreach ($handlers as $name => $desc) {
    if (stristr($name, $string) !== FALSE) {
      $matches[] = $name;
    }
  }
  return new JsonResponse($matches);
}