표준 symfony sfWebResponse를 확장했으며 응답에서 html을 수정하고 싶습니다.symfony 1.4 sfWebResponse sendContent 전에 내용 수정
이 작업을 수행하는 유일한 방법은 표준 sendContent 함수를 복제하고 에코되기 전에 $ content의 html을 수정하는 것입니다.
내가 잘못 생각하고 있습니까? (나는 느낌이있다).
표준 symfony sfWebResponse를 확장했으며 응답에서 html을 수정하고 싶습니다.symfony 1.4 sfWebResponse sendContent 전에 내용 수정
이 작업을 수행하는 유일한 방법은 표준 sendContent 함수를 복제하고 에코되기 전에 $ content의 html을 수정하는 것입니다.
내가 잘못 생각하고 있습니까? (나는 느낌이있다).
당신이 response.filter_content 이벤트들을 수 있습니다 : http://www.symfony-project.org/reference/1_4/en/15-Events#chapter_15_sub_response_filter_content
여기처럼 : https://github.com/vjousse/symfony-1.4/blob/master/lib/log/sfWebDebugLogger.class.php#L49
는, 필터를 만듭니다 바로 출력 (filter.yml의 순서) 전에 이동을하고 얻을 수있는 sfWebResponse를 사용하여 콘텐츠를 설정하십시오.
class makestuff extends sfFilter {
public function execute(sfFilterChain $filterChain) {
$filterChain->execute();
$response = $this->getContext()->getResponse();
$response->setContent( $response->getContent()." this comes after </html>");
}
}
감사합니다. 파스칼 덕분에 올바른 경로로 나를 보내 셨습니다. –
실제로 sfResponse 클래스에있는 것과 비슷한 것을 사용했습니다. $ this-> getContent());'$ event-> this-> dispatcher-> filter (새로운 sfEvent ($ this, 'response.filter_content' –