class PathSelection in Multi-path autocomplete 8
Provides specific selection functions for nodes.
Plugin annotation
@MpacSelection(
  id = "path",
  module = "mpac",
  label = @Translation("Path selection"),
  types = {"path"},
  group = "default",
  weight = 1
)
Hierarchy
- class \Drupal\mpac\Plugin\mpac\selection\SelectionBase implements SelectionInterface- class \Drupal\mpac\Plugin\mpac\selection\PathSelection
 
Expanded class hierarchy of PathSelection
File
- lib/Drupal/ mpac/ Plugin/ mpac/ selection/ PathSelection.php, line 26 
- Contains \Drupal\mpac\Plugin\mpac\selection\PathSelection.
Namespace
Drupal\mpac\Plugin\mpac\selectionView source
class PathSelection extends SelectionBase {
  public function countMatchingItems($match = NULL, $match_operator = 'CONTAINS') {
    $query = $this
      ->buildQuery($match, $match_operator);
    return $query
      ->count()
      ->execute();
  }
  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;
  }
  private function buildQuery($match = NULL, $match_operator = 'CONTAINS') {
    $query = db_select('url_alias');
    if (isset($match)) {
      $query
        ->condition('alias', '%' . $match . '%', 'LIKE');
    }
    return $query;
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| PathSelection:: | private | function | ||
| PathSelection:: | public | function | Counts items that matches against the given string. Overrides SelectionBase:: | |
| PathSelection:: | public | function | Returns a list of matching items. Overrides SelectionBase:: | |
| SelectionBase:: | public | function | Constructs a SelectionBase object. | 
