You are here

public function ParameterMap::toArray in Drupal 7 to 8/9 Module Upgrader 8

File

src/Routing/ParameterMap.php, line 46

Class

ParameterMap
Represents a set of parameter bindings for a particular path, callback, and set of arguments.

Namespace

Drupal\drupalmoduleupgrader\Routing

Code

public function toArray() {
  $output = [];
  foreach ($this->bindings as $key => $bindings) {
    if (is_integer($key)) {

      /** @var ParameterBinding[] $bindings */
      foreach ($bindings as $binding) {
        $parameter = $binding
          ->getParameter()
          ->getName();
        $function = $binding
          ->getParameter()
          ->getFunction()
          ->getName()
          ->getText();
        $output[$function][$parameter]['name'] = $bindings[0]
          ->getParameter()
          ->getName();
        $value = $bindings[0]
          ->getValue();
        if ($value instanceof PathComponent && $value
          ->isWildcard()) {
          $output[$function][$parameter]['type'] = ltrim($value, '%');
        }
      }
    }
  }
  return $output;
}