Loading CHANGELOG.txt +2 −0 Original line number Diff line number Diff line Search API 1.x, dev (xxxx-xx-xx): --------------------------------- - #3238635 by drunken monkey, mkalkbrenner: Added the AutocompleteBackendInterface. - #3221103 by drunken monkey: Fixed small bug in Views fulltext search filter. - #3255474 by murilohp, drunken monkey: Removed outdated test helper interfaces. - #2983640 by Nick_vh, L_VanDamme, drunken monkey, Marios Anagnostopoulos, Loading modules/search_api_db/src/Plugin/search_api/backend/Database.php +5 −25 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ use Drupal\Core\Logger\RfcLogLevel; use Drupal\Core\Plugin\PluginFormInterface; use Drupal\Core\Render\Element; use Drupal\search_api\Backend\BackendPluginBase; use Drupal\search_api\Contrib\AutocompleteBackendInterface; use Drupal\search_api\DataType\DataTypePluginManager; use Drupal\search_api\Entity\Index; use Drupal\search_api\IndexInterface; Loading Loading @@ -71,7 +72,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; * description = @Translation("Indexes items in the database. Supports several advanced features, but should not be used for large sites.") * ) */ class Database extends BackendPluginBase implements PluginFormInterface { class Database extends BackendPluginBase implements AutocompleteBackendInterface, PluginFormInterface { use PluginFormTrait; Loading Loading @@ -2647,30 +2648,9 @@ class Database extends BackendPluginBase implements PluginFormInterface { } /** * Retrieves autocompletion suggestions for some user input. * * @param \Drupal\search_api\Query\QueryInterface $query * A query representing the base search, with all completely entered words * in the user input so far as the search keys. * @param \Drupal\search_api_autocomplete\SearchInterface $search * An object containing details about the search the user is on, and * settings for the autocompletion. See the class documentation for details. * Especially $search->getOptions() should be checked for settings, like * whether to try and estimate result counts for returned suggestions. * @param string $incomplete_key * The start of another fulltext keyword for the search, which should be * completed. Might be empty, in which case all user input up to now was * considered completed. Then, additional keywords for the search could be * suggested. * @param string $user_input * The complete user input for the fulltext search keywords so far. * * @return \Drupal\search_api_autocomplete\Suggestion\SuggestionInterface[] * An array of autocomplete suggestions. * * @see \Drupal\search_api_autocomplete\AutocompleteBackendInterface::getAutocompleteSuggestions() */ public function getAutocompleteSuggestions(QueryInterface $query, SearchInterface $search, $incomplete_key, $user_input) { * {@inheritdoc} */ public function getAutocompleteSuggestions(QueryInterface $query, SearchInterface $search, string $incomplete_key, string $user_input): array { $settings = $this->configuration['autocomplete']; // If none of the options is checked, the user apparently chose a very Loading src/Contrib/AutocompleteBackendInterface.php 0 → 100644 +44 −0 Original line number Diff line number Diff line <?php namespace Drupal\search_api\Contrib; use Drupal\search_api\Query\QueryInterface; use Drupal\search_api\Backend\BackendInterface; use Drupal\search_api_autocomplete\SearchInterface; /** * Describes the method a backend plugin has to add to support autocompletion. * * In addition, the backend has to include "search_api_autocomplete" in the * return value of its getSupportedFeatures() implementation. * * This interface is present on behalf of the Search API Autocomplete * (search_api_autocomplete) module. */ interface AutocompleteBackendInterface extends BackendInterface { /** * Retrieves autocompletion suggestions for some user input. * * @param \Drupal\search_api\Query\QueryInterface $query * A query representing the base search, with all completely entered words * in the user input so far as the search keys. * @param \Drupal\search_api_autocomplete\SearchInterface $search * An object containing details about the search the user is on, and * settings for the autocompletion. See the class documentation for details. * Especially $search->getOptions() should be checked for settings, like * whether to try and estimate result counts for returned suggestions. * @param string $incomplete_key * The start of another fulltext keyword for the search, which should be * completed. Might be empty, in which case all user input up to now was * considered completed. Then, additional keywords for the search could be * suggested. * @param string $user_input * The complete user input for the fulltext search keywords so far. * * @return \Drupal\search_api_autocomplete\Suggestion\SuggestionInterface[] * An array of autocomplete suggestions. */ public function getAutocompleteSuggestions(QueryInterface $query, SearchInterface $search, string $incomplete_key, string $user_input): array; } Loading
CHANGELOG.txt +2 −0 Original line number Diff line number Diff line Search API 1.x, dev (xxxx-xx-xx): --------------------------------- - #3238635 by drunken monkey, mkalkbrenner: Added the AutocompleteBackendInterface. - #3221103 by drunken monkey: Fixed small bug in Views fulltext search filter. - #3255474 by murilohp, drunken monkey: Removed outdated test helper interfaces. - #2983640 by Nick_vh, L_VanDamme, drunken monkey, Marios Anagnostopoulos, Loading
modules/search_api_db/src/Plugin/search_api/backend/Database.php +5 −25 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ use Drupal\Core\Logger\RfcLogLevel; use Drupal\Core\Plugin\PluginFormInterface; use Drupal\Core\Render\Element; use Drupal\search_api\Backend\BackendPluginBase; use Drupal\search_api\Contrib\AutocompleteBackendInterface; use Drupal\search_api\DataType\DataTypePluginManager; use Drupal\search_api\Entity\Index; use Drupal\search_api\IndexInterface; Loading Loading @@ -71,7 +72,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; * description = @Translation("Indexes items in the database. Supports several advanced features, but should not be used for large sites.") * ) */ class Database extends BackendPluginBase implements PluginFormInterface { class Database extends BackendPluginBase implements AutocompleteBackendInterface, PluginFormInterface { use PluginFormTrait; Loading Loading @@ -2647,30 +2648,9 @@ class Database extends BackendPluginBase implements PluginFormInterface { } /** * Retrieves autocompletion suggestions for some user input. * * @param \Drupal\search_api\Query\QueryInterface $query * A query representing the base search, with all completely entered words * in the user input so far as the search keys. * @param \Drupal\search_api_autocomplete\SearchInterface $search * An object containing details about the search the user is on, and * settings for the autocompletion. See the class documentation for details. * Especially $search->getOptions() should be checked for settings, like * whether to try and estimate result counts for returned suggestions. * @param string $incomplete_key * The start of another fulltext keyword for the search, which should be * completed. Might be empty, in which case all user input up to now was * considered completed. Then, additional keywords for the search could be * suggested. * @param string $user_input * The complete user input for the fulltext search keywords so far. * * @return \Drupal\search_api_autocomplete\Suggestion\SuggestionInterface[] * An array of autocomplete suggestions. * * @see \Drupal\search_api_autocomplete\AutocompleteBackendInterface::getAutocompleteSuggestions() */ public function getAutocompleteSuggestions(QueryInterface $query, SearchInterface $search, $incomplete_key, $user_input) { * {@inheritdoc} */ public function getAutocompleteSuggestions(QueryInterface $query, SearchInterface $search, string $incomplete_key, string $user_input): array { $settings = $this->configuration['autocomplete']; // If none of the options is checked, the user apparently chose a very Loading
src/Contrib/AutocompleteBackendInterface.php 0 → 100644 +44 −0 Original line number Diff line number Diff line <?php namespace Drupal\search_api\Contrib; use Drupal\search_api\Query\QueryInterface; use Drupal\search_api\Backend\BackendInterface; use Drupal\search_api_autocomplete\SearchInterface; /** * Describes the method a backend plugin has to add to support autocompletion. * * In addition, the backend has to include "search_api_autocomplete" in the * return value of its getSupportedFeatures() implementation. * * This interface is present on behalf of the Search API Autocomplete * (search_api_autocomplete) module. */ interface AutocompleteBackendInterface extends BackendInterface { /** * Retrieves autocompletion suggestions for some user input. * * @param \Drupal\search_api\Query\QueryInterface $query * A query representing the base search, with all completely entered words * in the user input so far as the search keys. * @param \Drupal\search_api_autocomplete\SearchInterface $search * An object containing details about the search the user is on, and * settings for the autocompletion. See the class documentation for details. * Especially $search->getOptions() should be checked for settings, like * whether to try and estimate result counts for returned suggestions. * @param string $incomplete_key * The start of another fulltext keyword for the search, which should be * completed. Might be empty, in which case all user input up to now was * considered completed. Then, additional keywords for the search could be * suggested. * @param string $user_input * The complete user input for the fulltext search keywords so far. * * @return \Drupal\search_api_autocomplete\Suggestion\SuggestionInterface[] * An array of autocomplete suggestions. */ public function getAutocompleteSuggestions(QueryInterface $query, SearchInterface $search, string $incomplete_key, string $user_input): array; }