添加带注释的路径的要求

Jho*_*nne 3 symfony

我正在使用SensioFrameworkExtraBundle并尝试添加特定参数的要求.我希望参数匹配特定的字符串集合.

Symfony文档中的这个示例显示了我想要做的事情.我想做与文化和_format相同的事情.

article_show:
    path:     /articles/{culture}/{year}/{title}.{_format}
    defaults: { _controller: AcmeDemoBundle:Article:show, _format: html }
    requirements:
        culture:  en|fr
        _format:  html|rss
        year:     \d+
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

 /**
  * @Route("/{type}", requirements={"type" = {html|json|xml} }, name="adm_grid")
  * @Template
 */
Run Code Online (Sandbox Code Playgroud)

Eln*_*mov 7

你忘记了引号{html|json|xml},你不需要花括号:

 requirements={"type" = "html|json|xml"}
Run Code Online (Sandbox Code Playgroud)