我想知道是否可以修改请求参数的值。
但我不知道该怎么做。
我尝试
$requestContent = $this->getRequest()->request->get('tactill_customerbundle_customertype');
接下来我使用
$request->request->replace()
但我不知道如何在我的情况下使用这种方法。
由于
答案 0 :(得分:30)
replace
方法取代了请求中所有的参数,因此您可能不希望这样做。
我会使用set
方法 - 所以你可以这样做:
$request->request->set('tactill_customerbundle_customertype', $newValue)
您可以在Symfony2文档(http://api.symfony.com/2.0/)中阅读更多内容 - 您正在寻找Symfony\Component\HttpFoundation\Request
($request
变量),然后在Symfony\Component\HttpFoundation\ParameterBag
变量时返回request()
你调用{{1}}方法。