Symfony 2.0 - How to create route with array-parameters?

烈酒焚心 提交于 2019-12-05 19:58:39

You can use it as a string and just serialize() the content before and after.

As far as I know symfony2 doesn't allow arrays in routing, how would the URL Look with an array in? A URL has to be a string, so serializing the array and passing it as a string is probably a better option.

I agree with @JamesHalsall about serializing. I would also add that the serialized string should then be urlencoded before being used as a GET parameter.

You have to validate the route, so either use some contrived event handling (see the kernel.controller event ) or use a controller that simply redirects to a new URL if the Name is in the array or displays an error page.

Also you could experiment with the ChainRouter that is a replacement for the default Symfony2 router (supports Doctrine-based routing and such).

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!