You are here

public function DummyMatcher::getMatches in Linkit 8.4

Gets an array with search matches that will be presented in the autocomplete widget.

Parameters

$string: The string that contains the text to search for.

Return value

array An array whose values are an associative array containing:

  • title: A string to use as the search result label.
  • description: (optional) A string with additional information about the result item.
  • path: The URL to the item.
  • group: (optional) A string with the group name for the result item. Best practice is to use the plugin name as group name.

Overrides MatcherInterface::getMatches

File

tests/linkit_test/src/Plugin/Linkit/Matcher/DummyMatcher.php, line 36
Contains \Drupal\linkit_test\Plugin\Linkit\Matcher\DummyMatcher.

Class

DummyMatcher
Plugin annotation @Matcher( id = "dummy_matcher", label = @Translation("Dummy Matcher"), )

Namespace

Drupal\linkit_test\Plugin\Linkit\Matcher

Code

public function getMatches($string) {
  $matches[] = [
    'title' => 'DummyMatcher title',
    'description' => 'DummyMatcher description',
    'path' => 'http://example.com',
    'group' => 'DummyMatcher',
  ];
  return $matches;
}