How do I retrieve the query parameters from a path. Here's my path:
/search?keys=hello
Here is what I've tried:
$test1 = \Drupal::request()->request->get('name');
$test2 = \Drupal::request()->query->get('name');
$test3 = \Drupal::service('path.current')->getPath();
$test4 = \Drupal::request()->server->get('REQUEST_METHOD');
$test5 = \Drupal::request()->query->get('q');
$test6 = \Drupal::request()->request->get('keys');
$test7 = \Drupal::request()->query->get('keys');
$test8 = \Drupal::request()->query->get('destination');
$test9 = \Drupal::request()->request->all();
$test10 = \Drupal::request()->getRequestUri();
Here are the results:
Test 1: NULL
Test 2: NULL
Test 3: '/search'
Test 4: 'GET'
Test 5: NULL
Test 6: NULL
Test 7: NULL
Test 8: NULL
Test 9: array ( )
Test 10: '/search'
Why is this not working?