Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Matches.php

function Matches::map

Replaces all the matches with the result of the given function. The function will receive the node and its parent as arguments and must return an array of matches

Parameters

callable $fn Map function:

Return value

$this

File

vendor/mck89/peast/lib/Peast/Selector/Matches.php, line 99

Class

Matches
Selector matches class

Namespace

Peast\Selector

Code

public function map(callable $fn) {
    $newMatches = array();
    foreach ($this->matches as $match) {
        $res = $fn($match[0], $match[1]);
        if ($res) {
            $newMatches = array_merge($newMatches, $res);
        }
    }
    $this->matches = $newMatches;
    return $this->unique();
}
RSS feed
Powered by Drupal