여러 매개 변수를 사용하여 특정 모델을 필터링 할 수있는 Symfony2의 오픈 소스 (또는 예제) 코드가 있습니까? 이 Trulia 웹 페이지에서 제가 찾고있는 좋은 예가 보입니다.symfony2로 필터링
http://www.trulia.com/for_sale/30000-1000000_price/10001_zip/
http://www.trulia.com/for_rent/Chicago,IL/#for_rent/Chicago,IL/0-500_price/wd,dw_amenities/sm_dogs_pets"
http://www.trulia.com/for_rent/Chicago,IL/#for_rent/Chicago,IL/400-500_price/wd,dw_amenities
http://www.trulia.com/for_rent/Chicago,IL/#for_rent/Chicago,IL/wd,dw_amenities"
http://www.trulia.com/for_rent/Chicago,IL/#for_rent/Chicago,IL/400p_price/dw,cs_amenities
http://www.trulia.com/for_rent/Chicago,IL/#for_rent/Chicago,IL/1p_beds/1p_baths/400p_price/dw,cs_amenities
양식을 클릭하면 URL이 어떻게 생성되는지 알 수 있습니다.이 모든 경로에 대해 하나의 컨트롤러를 사용하고 있습니다. 어떻게 끝났습니까? I 가능한 모든 경로를 특정 컨트롤러로 리다이렉트 할 것 같지 않습니다 (아래 참조). 일종의 동적 라우팅일까요?
/**
* @Route("/for_rent/{state}/{beds}_beds/{bath}_bath/{mix_price}-{max_price}_price /{amenities_list}
* @Route("/for_rent/{state}/{mix_price}-{max_price}_price/{amenities_list}
* @Route("/for_rent/{state}/{bath}_bath/{mix_price}-{max_price}_price/{amenities_list}
* @Route("/for_rent/{state}/{mix_price}_price/{amenities_list}
* @Route("/for_rent/{state}/{beds}_beds/{bath}_bath/{amenities_list}
* ........
*/
public function filterAction($state, $beds, $bath, $min_price, $max_price ....)
{
....
}
감사합니다.
주석 당신은 위대 하나 개 이상의 경로를 일치시킬 수 있습니다,하지만 당신은 모든 필터 매개 변수를 수동으로 가능한 모든 조합을 쓰고 피하지 않는 내 말은, 가능한 모든 경로의 조합이 될 것입니다 ABC 매개 변수를 가지고, ABC, AB, BC, AC, 고통입니다. 나 자신의 라우팅 구현이 동적 URL 일치의 종류를 허용할지 여부를 모르겠다. – csg
매우 간단한 해결책을 찾았습니다/** * @Route ("/ search/{q}", 요구 사항 = { "q": ". +"}) * ........ */ q는 URL의 끝까지 모든 것을 일치시킵니다. 그런 다음 "q"를 구문 분석하면됩니다. 자세한 정보는 http://symfony.com/doc/current/cookbook/routing/slash_in_parameter.html을 참조하십시오. – csg