public function ParameterMap::applyRoute in Drupal 7 to 8/9 Module Upgrader 8
Apply the parameter map to a Drupal 8 route, modifying it as needed.
Parameters
\Symfony\Component\Routing\Route $route: The route to process.
File
- src/
Routing/ ParameterMap.php, line 135
Class
- ParameterMap
- Represents a set of parameter bindings for a particular path, callback, and set of arguments.
Namespace
Drupal\drupalmoduleupgrader\RoutingCode
public function applyRoute(Drupal8Route $route) {
$this
->applyPath($this->path);
foreach ($this as $key => $binding) {
$parameter = $binding
->getParameter();
/** @var ParameterBinding $binding */
if (is_integer($key)) {
if ($parameter
->isOptional()) {
// @todo Don't use eval().
$value = eval('return ' . $parameter
->getValue() . ';');
$route
->setDefault($parameter
->getName(), $value);
}
}
elseif ($binding
->hasArgument()) {
$route
->setDefault($parameter
->getName(), $binding
->getValue());
}
}
$route
->setPath($this->path
->__toString());
}