For example, link:
/shop/phones/brend/apple/display/retina/color/red
where:
phones - category alias
brend - name of attribute; apple - attribute value
display - name of attribute; retina - attribute value
color - name of attribute; red - attribute value
Attributes can be any number. Order may also be different.
The beginning of the route is clear:
/shop/{category}
And what to do next is unclear.
In symfony 1, a set at the end star ("/shop/:category/*") and all that was not clearly marked, and come in a pair of
name -> value
Question: how to describe the route in symfony 2?
The route:
my_shop:
pattern: "/{path}"
defaults: { _controller: "MyShopBundle:Default:shop" }
requirements:
path: "^shop/.+"
and then you could just parse the $path in the controller:
class DefaultController extends Controller {
...
public function shopAction($path) {
// $path will be 'shop/phones/brend/apple/display/retina/color/red'
...
}
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With