Loading core/modules/views/src/Plugin/views/argument_default/QueryParameter.php +6 −2 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Drupal\views\Plugin\views\argument_default; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheableDependencyInterface; use Drupal\Core\Form\FormStateInterface; Loading Loading @@ -64,9 +65,12 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { */ public function getArgument() { $current_request = $this->view->getRequest(); // Convert a[b][c][d] into ['a', 'b', 'c', 'd']. $path = array_filter(preg_split('#(\[|\]\[|\])#', $this->options['query_param'])); if ($current_request->query->has($this->options['query_param'])) { $param = $current_request->query->all()[$this->options['query_param']]; if ($current_request->query->has($path[0])) { $query = $current_request->query->all(); $param = NestedArray::getValue($query, $path); if (is_array($param)) { $conjunction = ($this->options['multiple'] == 'and') ? ',' : '+'; $param = implode($conjunction, $param); Loading core/modules/views/tests/src/Unit/Plugin/argument_default/QueryParameterTest.php +18 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,24 @@ public function providerGetArgument() { 'blub', ]; $data[] = [ ['query_param' => 'test[tier1][tier2][tier3]'], new Request(['test' => ['tier1' => ['tier2' => ['tier3' => 'foo']]]]), 'foo', ]; $data[] = [ ['query_param' => 'test[tier1][tier2]'], new Request(['test' => ['tier1' => ['tier2' => ['foo', 'bar']]]]), 'foo,bar', ]; $data[] = [ ['query_param' => 'test[tier1][tier2]'], new Request(['test' => 'foo']), NULL, ]; return $data; } Loading Loading
core/modules/views/src/Plugin/views/argument_default/QueryParameter.php +6 −2 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Drupal\views\Plugin\views\argument_default; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheableDependencyInterface; use Drupal\Core\Form\FormStateInterface; Loading Loading @@ -64,9 +65,12 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { */ public function getArgument() { $current_request = $this->view->getRequest(); // Convert a[b][c][d] into ['a', 'b', 'c', 'd']. $path = array_filter(preg_split('#(\[|\]\[|\])#', $this->options['query_param'])); if ($current_request->query->has($this->options['query_param'])) { $param = $current_request->query->all()[$this->options['query_param']]; if ($current_request->query->has($path[0])) { $query = $current_request->query->all(); $param = NestedArray::getValue($query, $path); if (is_array($param)) { $conjunction = ($this->options['multiple'] == 'and') ? ',' : '+'; $param = implode($conjunction, $param); Loading
core/modules/views/tests/src/Unit/Plugin/argument_default/QueryParameterTest.php +18 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,24 @@ public function providerGetArgument() { 'blub', ]; $data[] = [ ['query_param' => 'test[tier1][tier2][tier3]'], new Request(['test' => ['tier1' => ['tier2' => ['tier3' => 'foo']]]]), 'foo', ]; $data[] = [ ['query_param' => 'test[tier1][tier2]'], new Request(['test' => ['tier1' => ['tier2' => ['foo', 'bar']]]]), 'foo,bar', ]; $data[] = [ ['query_param' => 'test[tier1][tier2]'], new Request(['test' => 'foo']), NULL, ]; return $data; } Loading