Routing, an unlimited number of parameters

前端 未结 1 1362
旧时难觅i
旧时难觅i 2021-01-05 22:53

For example, link:

/shop/phones/brend/apple/display/retina/color/red

where:

phones    - category alias
brend     - name of          


        
相关标签:
1条回答
  • 2021-01-05 23:33

    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'
            ...
        }
    ...
    }
    
    0 讨论(0)
提交回复
热议问题