You are here

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

Adds a binding to this map, overwriting the existing one if there is a conflict.

Parameters

ParameterBinding $binding: The binding to add.

2 calls to ParameterMap::addBinding()
ParameterMap::merge in src/Routing/ParameterMap.php
Merge another parameter map into this one. Bindings from the incoming map should 'win', although the specifics are up to the implementing classes.
ParameterMap::__construct in src/Routing/ParameterMap.php

File

src/Routing/ParameterMap.php, line 88

Class

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

Namespace

Drupal\drupalmoduleupgrader\Routing

Code

public function addBinding(ParameterBinding $binding) {
  $value = $binding
    ->getValue();

  // The binding will return a PathComponent if it expects to be physically
  // represented in the path, whether or not it already is.
  if ($value instanceof PathComponent) {
    if ($binding
      ->inPath()) {
      $key = $binding
        ->getArgument();
    }
    else {
      $key = $this->path
        ->indexOf($value);
      if ($key === FALSE) {
        $key = $this->_length++;
      }
    }
  }
  else {
    $key = $binding
      ->getParameter()
      ->getName();
  }
  $this
    ->set($key, $binding);
  if (!isset($this->bindings[$key])) {
    $this->bindings[$key] = [];
  }
  array_unshift($this->bindings[$key], $binding);
}