路由,参数
问题描述:
例如数量不受限制,连结:路由,参数
/shop/phones/brend/apple/display/retina/color/red
其中:
phones - category alias
brend - name of attribute; apple - attribute value
display - name of attribute; retina - attribute value
color - name of attribute; red - attribute value
属性可以是任何数量。顺序也可能不同。
路线的开始是明确的:
/shop/{category}
而接下来要做的事还不清楚。
在symfony中1,一组末星(“/店/:类/ *”)以及所有的一切没有明确标注,并拿出一对
name -> value
的问题:如何在symfony 2中描述路线?
答
路线:
my_shop:
pattern: "/{path}"
defaults: { _controller: "MyShopBundle:Default:shop" }
requirements:
path: "^shop/.+"
,然后你可以只解析在控制器中的$ PATH:
class DefaultController extends Controller {
...
public function shopAction($path) {
// $path will be 'shop/phones/brend/apple/display/retina/color/red'
...
}
...
}