Loading core/modules/views/src/Plugin/views/argument_default/QueryParameter.php +6 −7 Original line number Diff line number Diff line Loading @@ -69,9 +69,9 @@ public function getArgument() { // Convert a[b][c][d] into ['a', 'b', 'c', 'd']. $path = array_filter(preg_split('#(\[|\]\[|\])#', $this->options['query_param'])); if ($current_request->query->has($path[0])) { $query = $current_request->query->all(); $param = NestedArray::getValue($query, $path); $param = NestedArray::getValue($query, $path, $key_exists); if ($key_exists) { if (is_array($param)) { $conjunction = ($this->options['multiple'] == 'and') ? ',' : '+'; $param = implode($conjunction, $param); Loading @@ -79,11 +79,10 @@ public function getArgument() { return $param; } else { // Otherwise, use the fixed fallback value. return $this->options['fallback']; } } /** * {@inheritdoc} Loading core/modules/views/tests/src/Unit/Plugin/argument_default/QueryParameterTest.php +12 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,18 @@ public static function providerGetArgument() { NULL, ]; $data[] = [ ['query_param' => 'test[tier1][tier2]', 'fallback' => 'baz'], new Request(['test' => ['tier1' => 'foo']]), 'baz', ]; $data[] = [ ['query_param' => 'test[tier1][tier2]', 'fallback' => 'baz'], new Request(['test' => ['test2' => 'foo']]), 'baz', ]; return $data; } Loading Loading
core/modules/views/src/Plugin/views/argument_default/QueryParameter.php +6 −7 Original line number Diff line number Diff line Loading @@ -69,9 +69,9 @@ public function getArgument() { // Convert a[b][c][d] into ['a', 'b', 'c', 'd']. $path = array_filter(preg_split('#(\[|\]\[|\])#', $this->options['query_param'])); if ($current_request->query->has($path[0])) { $query = $current_request->query->all(); $param = NestedArray::getValue($query, $path); $param = NestedArray::getValue($query, $path, $key_exists); if ($key_exists) { if (is_array($param)) { $conjunction = ($this->options['multiple'] == 'and') ? ',' : '+'; $param = implode($conjunction, $param); Loading @@ -79,11 +79,10 @@ public function getArgument() { return $param; } else { // Otherwise, use the fixed fallback value. return $this->options['fallback']; } } /** * {@inheritdoc} Loading
core/modules/views/tests/src/Unit/Plugin/argument_default/QueryParameterTest.php +12 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,18 @@ public static function providerGetArgument() { NULL, ]; $data[] = [ ['query_param' => 'test[tier1][tier2]', 'fallback' => 'baz'], new Request(['test' => ['tier1' => 'foo']]), 'baz', ]; $data[] = [ ['query_param' => 'test[tier1][tier2]', 'fallback' => 'baz'], new Request(['test' => ['test2' => 'foo']]), 'baz', ]; return $data; } Loading