You are here

public function QueryPath::replaceWith in QueryPath 6

Same name and namespace in other branches
  1. 7.3 QueryPath/QueryPath.php \QueryPath::replaceWith()
  2. 7.2 QueryPath/QueryPath.php \QueryPath::replaceWith()

File

QueryPath/QueryPath.php, line 722

Class

QueryPath

Code

public function replaceWith($new) {
  $data = $this
    ->prepareInsert($new);
  $found = new SplObjectStorage();
  foreach ($this->matches as $m) {
    $parent = $m->parentNode;
    $parent
      ->insertBefore($data
      ->cloneNode(TRUE), $m);
    $found
      ->attach($parent
      ->removeChild($m));
  }
  $this
    ->setMatches($found);
  return $this;
}