You are here

public function JsonPathReplacer::replaceBatch in Subrequests 8.2

Same name and namespace in other branches
  1. 3.x src/JsonPathReplacer.php \Drupal\subrequests\JsonPathReplacer::replaceBatch()

Performs the JSON Path replacements in the whole batch.

Parameters

\Drupal\subrequests\Subrequest[] $batch: The subrequests that contain replacement tokens.

\Symfony\Component\HttpFoundation\Response[] $responses: The accumulated responses from previous requests.

Return value

\Drupal\subrequests\Subrequest[] An array of subrequests. Note that one input subrequest can generate N output subrequests. This is because JSON path expressinos can return multiple values.

1 call to JsonPathReplacer::replaceBatch()
JsonPathReplacer::replaceItem in src/JsonPathReplacer.php
Searches for JSONPath tokens in the request and replaces it with the values from previous responses.

File

src/JsonPathReplacer.php, line 25

Class

JsonPathReplacer

Namespace

Drupal\subrequests

Code

public function replaceBatch(array $batch, array $responses) {
  return array_reduce($batch, function (array $carry, Subrequest $subrequest) use ($responses) {
    return array_merge($carry, $this
      ->replaceItem($subrequest, $responses));
  }, []);
}