You are here

public function PathSelection::getMatchingItems in Multi-path autocomplete 8

Returns a list of matching items.

Return value

array An array of path items. Keys are the system paths of the items and values are (safe HTML) titles of the corresponding pages.

Overrides SelectionBase::getMatchingItems

File

lib/Drupal/mpac/Plugin/mpac/selection/PathSelection.php, line 35
Contains \Drupal\mpac\Plugin\mpac\selection\PathSelection.

Class

PathSelection
Provides specific selection functions for nodes.

Namespace

Drupal\mpac\Plugin\mpac\selection

Code

public function getMatchingItems($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
  if (!isset($match)) {
    return array();
  }
  $query = $this
    ->buildQuery($match, $match_operator);
  $result = $query
    ->fields('url_alias')
    ->execute();
  if (empty($result)) {
    return array();
  }
  $matches = array();
  foreach ($result as $data) {
    $matches[$data->source] = sprintf('%s *', $data->alias);
  }
  return $matches;
}