【发布时间】:2011-08-03 16:26:39
【问题描述】:
是否有任何 Symfony2 的开源(或示例)代码可以使用多个参数过滤某些模型?在这个 Trulia 网页上可以看到我正在寻找的一个很好的例子。
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 是如何构建的,我猜是对所有这些路由使用一个控制器,它是如何完成的? 我认为它不会将所有可能的路由重定向到特定的控制器(如下所示),也许是某种动态路由?
/**
* @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 ....)
{
....
}
谢谢。
【问题讨论】:
标签: php url-routing symfony