class MpacAutocompleteController in Multi-path autocomplete 8
Controller routines for mpax autocomplete routes.
Hierarchy
- class \Drupal\mpac\MpacAutocompleteController implements ContainerInjectionInterface
Expanded class hierarchy of MpacAutocompleteController
File
- lib/
Drupal/ mpac/ MpacAutocompleteController.php, line 17 - Contains \Drupal\mpac\MpacAutocompleteController.
Namespace
Drupal\mpacView source
class MpacAutocompleteController implements ContainerInjectionInterface {
/**
* The mpac autocomplete helper class to find matching items.
*
* @var \Drupal\mpac\MpacAutocomplete
*/
protected $mpacAutocomplete;
/**
* Constructs an MpacAutocompleteController object.
*
* @param \Drupal\mpac\MpacAutocomplete $mpac_autocomplete
* The mpac autocomplete helper class to find matching items.
*/
public function __construct(MpacAutocomplete $mpac_autocomplete) {
$this->mpacAutocomplete = $mpac_autocomplete;
}
/**
* Implements \Drupal\Core\ControllerInterface::create().
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('mpac.autocomplete'));
}
/**
* Returns response for the mpac autocompletion.
*
* @param Request $request
* The current request object containing the search string.
* @param string $type
* The type of data to find (i.e. "path" or "shortcut").
*
* @return JsonResponse
* A JSON response containing the autocomplete suggestions for existing users.
*
* @see MpacAutocomplete::getMatches()
*/
public function autocompleteItems(Request $request, $type) {
$matches = $this->mpacAutocomplete
->getMatches($type, $request->query
->get('q'));
return new JsonResponse($matches);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MpacAutocompleteController:: |
protected | property | The mpac autocomplete helper class to find matching items. | |
MpacAutocompleteController:: |
public | function | Returns response for the mpac autocompletion. | |
MpacAutocompleteController:: |
public static | function |
Implements \Drupal\Core\ControllerInterface::create(). Overrides ContainerInjectionInterface:: |
|
MpacAutocompleteController:: |
public | function | Constructs an MpacAutocompleteController object. |