带有容器参数的 Symfony 2 路由注释 [英] Symfony 2 Routing Annotation with container parameter

查看:25
本文介绍了带有容器参数的 Symfony 2 路由注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 yml 路由移植"到注释.在 yml 我有路线:

I am trying to "port" yml routing to annotations. In yml I have route:

homepage_foo:
    pattern:  /foo
    defaults: { _controller: FooBundle:Homepage:foo }
    schemes:  [%httpProtocol%]

其中 %httpProtocol% 是来自容器的参数.

where %httpProtocol% is parameter from container.

使用注释,类似的方法不起作用:

With annotation, similar approach is not working:

/**
  * @Route("/foo", name="homepage_foo", schemes={%httpProtocol%})
  */

我正在尝试使用带注释的参数 %httpProtocol%.是否可以使用不同的语法?

I am trying to use parameter %httpProtocol% with annotation. Is it possible with different syntax?

推荐答案

适用于:

/**
 * @Route("/foo", name="homepage_foo", schemes="%httpProtocol%")
 */

这篇关于带有容器参数的 Symfony 2 路由注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆