protected function ParamConversionEnhancer::copyRawVariables in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php \Drupal\Core\Routing\Enhancer\ParamConversionEnhancer::copyRawVariables()
- 10 core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php \Drupal\Core\Routing\Enhancer\ParamConversionEnhancer::copyRawVariables()
Store a backup of the raw values that corresponding to the route pattern.
Parameters
array $defaults: The route defaults array.
Return value
\Symfony\Component\HttpFoundation\ParameterBag
1 call to ParamConversionEnhancer::copyRawVariables()
- ParamConversionEnhancer::enhance in core/
lib/ Drupal/ Core/ Routing/ Enhancer/ ParamConversionEnhancer.php - Update the defaults based on its own data and the request.
File
- core/
lib/ Drupal/ Core/ Routing/ Enhancer/ ParamConversionEnhancer.php, line 58
Class
- ParamConversionEnhancer
- Provides a route enhancer that handles parameter conversion.
Namespace
Drupal\Core\Routing\EnhancerCode
protected function copyRawVariables(array $defaults) {
/** @var $route \Symfony\Component\Routing\Route */
$route = $defaults[RouteObjectInterface::ROUTE_OBJECT];
$variables = array_flip($route
->compile()
->getVariables());
// Foreach will copy the values from the array it iterates. Even if they
// are references, use it to break them. This avoids any scenarios where raw
// variables also get replaced with converted values.
$raw_variables = [];
foreach (array_intersect_key($defaults, $variables) as $key => $value) {
$raw_variables[$key] = $value;
}
return new ParameterBag($raw_variables);
}