You are here

public function QueryPath::setMatches in QueryPath 6

Same name and namespace in other branches
  1. 7.3 QueryPath/QueryPath.php \QueryPath::setMatches()
  2. 7.2 QueryPath/QueryPath.php \QueryPath::setMatches()
40 calls to QueryPath::setMatches()
QueryPath::append in QueryPath/QueryPath.php
QueryPath::children in QueryPath/QueryPath.php
QueryPath::cloneAll in QueryPath/QueryPath.php
QueryPath::closest in QueryPath/QueryPath.php
QueryPath::contents in QueryPath/QueryPath.php

... See full list

File

QueryPath/QueryPath.php, line 1889

Class

QueryPath

Code

public function setMatches($matches, $unique = TRUE) {
  $this->last = $this->matches;
  if ($matches instanceof SplObjectStorage) {
    $this->matches = $matches;
  }
  elseif (is_array($matches)) {
    trigger_error('Legacy array detected.');
    $tmp = new SplObjectStorage();
    foreach ($matches as $m) {
      $tmp
        ->attach($m);
    }
    $this->matches = $tmp;
  }
  else {
    $found = new SplObjectStorage();
    if (isset($matches)) {
      $found
        ->attach($matches);
    }
    $this->matches = $found;
  }
  $this->length = $this->matches
    ->count();
}