1

How to reach the parameters Array into the Request object? For example in doneAction(), I want to get the parameter from the url such as this example:

www.example.com/en/done?payum_token=76BQZfpdjV1rOGye_y5WZr0vOpkyCKm2vstkOsZvjOE

public function doneAction(Request $request)
{
    dump($request);
    dump($request->query);
    dump($request->query->getparameters());
}

enter image description here

When I try with $request->query->getparameters() I have got an error:

enter image description here

I also tried $request->query->parameters

enter image description here

1

1 Answer 1

4

You can do:

$request->query->get('payum_token');

If you look at your debug, we see that the query is a ParameterBag object. So you can access the Symfony API and see what are the public methods provided by this class. For example for the get method:

http://api.symfony.com/3.4/Symfony/Component/HttpFoundation/ParameterBag.html#method_get

Note that this method returns null if the parameter isn't found. If you want to have another value if the parameter is not found, then pass it as the 2nd argument:

$request->query->get('payum_token', 'default_value');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.