Skip to content
Snippets Groups Projects
Verified Commit 7e48dd85 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3277784 by Tim Bozeman, mrinalini9, larowlan: copyRawVariables should...

Issue #3277784 by Tim Bozeman, mrinalini9, larowlan: copyRawVariables should support default route parameters

(cherry picked from commit ca0a26d2)
parent c56d99c5
Branches
Tags
5 merge requests!8506Draft: Issue #3456536 by ibrahim tameme,!5646Issue #3350972 by nod_: [random test failure]...,!5600Issue #3350972 by nod_: [random test failure]...,!5343Issue #3305066 by quietone, Rename RedirectLeadingSlashesSubscriber,!3603#ISSUE 3346218 Add a different message on edit comment
......@@ -67,6 +67,13 @@ protected function copyRawVariables(array $defaults) {
foreach (array_intersect_key($defaults, $variables) as $key => $value) {
$raw_variables[$key] = $value;
}
// Route defaults that do not start with a leading "_" are also
// parameters, even if they are not included in path or host patterns.
foreach ($route->getDefaults() as $name => $value) {
if (!isset($raw_variables[$name]) && substr($name, 0, 1) !== '_') {
$raw_variables[$name] = $value;
}
}
return new InputBag($raw_variables);
}
......
......@@ -75,6 +75,7 @@ public function testEnhance() {
*/
public function testCopyRawVariables() {
$route = new Route('/test/{id}');
$route->setDefault('node_type', 'page');
$defaults = [
RouteObjectInterface::ROUTE_OBJECT => $route,
'id' => '1',
......@@ -90,7 +91,10 @@ public function testCopyRawVariables() {
return $defaults;
});
$expected = new InputBag(['id' => 1]);
$expected = new InputBag([
'id' => '1',
'node_type' => 'page',
]);
$result = $this->paramConversionEnhancer->enhance($defaults, new Request());
$this->assertEquals($result['_raw_variables'], $expected);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment