2012-05-22 3 views
21

요청 매개 변수 값을 수정할 수 있는지 알고 싶습니다.요청 매개 변수 값 수정

하지만 어떻게해야할지 모르겠다.

은 내가

$request->request->replace() 

를 사용

$requestContent = $this->getRequest()->request->get('tactill_customerbundle_customertype'); 

다음과 시도하지만 내 경우에이 방법을 사용하지 않는 방법에 대해 설명합니다. 당신은 아마 그렇게하고 싶지 않아 그래서

감사

답변

27

replace 방법은 요청의 모든 매개 변수을 대체합니다.

내가 대신 set 방법을 사용합니다 - 그래서 당신은 할 수 있습니다 :

$request->request->set('tactill_customerbundle_customertype', $newValue) 

당신은 Symfony2 문서에서 자세한 내용을보실 수 있습니다 (http://api.symfony.com/2.0/) - 당신이합니다 ($request 변수 인) Symfony\Component\HttpFoundation\Request을 찾고있는 request() 메서드를 호출하면 Symfony\Component\HttpFoundation\ParameterBag을 반환합니다.

+13

'''replace()'''': 사용 : '''$ all = $ request-> request-> all(); $ [tactill_customerbundle_customertype '] = $ newValue; $ request-> request-> replace ($ all);''''이것은 배열 매개 변수 수정을 허용합니다. –