In symfony 2 controllers, every time I want to get a value from post I need to run:
$this->getRequest()->get('value1'); $this->getRequest()->get('value2');
Is there any way to consolidate these into one statement that would return an array? Something like Zend's getParams()?
You can do $this->getRequest()->query->all();
to get all GET params and $this->getRequest()->request->all();
to get all POST params.
So in your case:
$params = $this->getRequest()->request->all(); $params['value1']; $params['value2'];
For more info about the Request class, see http://api.symfony.com/2.8/Symfony/Component/HttpFoundation/Request.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With