You are here

protected function JsonPathReplacer::getPoints in Subrequests 8.2

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

Generates a list of sets of coordinates for the token replacements.

Each point (coordinates set) end up creating a new clone of the tokenized subrequest.

Parameters

array $grouped_by_token: Replacements grouped by token.

Return value

array The coordinates sets.

1 call to JsonPathReplacer::getPoints()
JsonPathReplacer::doReplaceTokensInLocation in src/JsonPathReplacer.php
Creates replacements for either the body or the URI.

File

src/JsonPathReplacer.php, line 168

Class

JsonPathReplacer

Namespace

Drupal\subrequests

Code

protected function getPoints($grouped_by_token) {
  $current_group = array_shift($grouped_by_token);

  // If this is not the last group, then call recursively.
  if (empty($grouped_by_token)) {
    return array_map(function ($item) {
      return [
        $item,
      ];
    }, $current_group);
  }
  $points = [];
  foreach ($current_group as $resolution_info) {

    // Get all the combinations for the next groups.
    $next_points = $this
      ->getPoints($grouped_by_token);
    foreach ($next_points as $next_point) {

      // Prepend the current resolution for each point.
      $points[] = array_merge([
        $resolution_info,
      ], $next_point);
    }
  }
  return $points;
}