I created a service and it works as well.

A piece of my code from "event_subscriber":

public function addRequestAddValue(GetResponseEvent $event) {
  $request = $event->getRequest();
  $request->query->add(['key' => '123']);

And than I try get this param on my Controller all Ok:

$key = \Drupal::request()->query->get('key');
dsm($key); // return 123

But if I try get URL I can see only:

$url = \Drupal::request()->getUri();
dsm($url); //return http://localhoct.dv/patn

What I need do to get URI with GET param?




Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.