search_api_autocomplete.interface.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * @file
  4. * Contains the SearchApiAutocompleteInterface.
  5. */
  6. /**
  7. * Interface describing the method a service class has to add to support autocompletion.
  8. *
  9. * Please note that this interface is purely documentational. You shouldn't, and
  10. * can't, implement it explicitly.
  11. */
  12. interface SearchApiAutocompleteInterface extends SearchApiServiceInterface {
  13. /**
  14. * Get autocompletion suggestions for some user input.
  15. *
  16. * For example, when given the user input "teach us", with "us" being
  17. * considered incomplete, the following might be returned:
  18. * @code
  19. * array(
  20. * array(
  21. * 'prefix' => t('Did you mean:'),
  22. * 'user_input' => 'reach us',
  23. * ),
  24. * array(
  25. * 'user_input' => 'teach us',
  26. * 'suggestion_suffix' => 'ers',
  27. * ),
  28. * array(
  29. * 'user_input' => 'teach us',
  30. * 'suggestion_suffix' => ' swimming',
  31. * ),
  32. * 'teach users swimming',
  33. * );
  34. * @endcode
  35. *
  36. * @param SearchApiQueryInterface $query
  37. * A query representing the completed user input so far.
  38. * @param SearchApiAutocompleteSearch $search
  39. * An object containing details about the search the user is on, and
  40. * settings for the autocompletion. See the class documentation for details.
  41. * Especially $search->options should be checked for settings, like whether
  42. * to try and estimate result counts for returned suggestions.
  43. * @param string $incomplete_key
  44. * The start of another fulltext keyword for the search, which should be
  45. * completed. Might be empty, in which case all user input up to now was
  46. * considered completed. Then, additional keywords for the search could be
  47. * suggested.
  48. * @param string $user_input
  49. * The complete user input for the fulltext search keywords so far.
  50. *
  51. * @return array
  52. * An array of suggestion. Each suggestion is either a simple string
  53. * containing the whole suggested keywords, or an array containing the
  54. * following keys:
  55. * - prefix: For special suggestions, some kind of prefix describing them.
  56. * - suggestion_prefix: A suggested prefix for the entered input.
  57. * - user_input: The input entered by the user. Defaults to $user_input.
  58. * - suggestion_suffix: A suggested suffix for the entered input.
  59. * - results: If available, the estimated number of results for these keys.
  60. * One of "suggestion_prefix" and "suggestion_suffix" has to be present, all
  61. * other keys are optional. The search keys inserted for the suggestion will
  62. * be a direct concatenation (no spaces in between) of "suggestion_prefix",
  63. * "user_input" and "suggestion_suffix".
  64. */
  65. public function getAutocompleteSuggestions(SearchApiQueryInterface $query, SearchApiAutocompleteSearch $search, $incomplete_key, $user_input);
  66. }