2014-10-01 45 views
2

我想“端口”yml路由到注释。 在YML我有路线:Symfony 2路由注解与容器参数

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

其中%httpProtocol%是从容器的参数。

有了注释,类似的做法是行不通的:

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

我试图使用参数%httpProtocol%与注解。用不同的语法可能吗?

+0

你有[导入的注释](http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/routing.html#activation)为该控制器(或对全部)? – 2014-10-01 17:09:56

+0

是的,对不起,注释本身就是有效的。我修正了问题,它不适用于'schemes = {%httpProtocol%}' – 2014-10-01 17:15:22

+0

尝试像在“名称占位符”中那样添加:'schemes = {httpProtocol}'和requirements = {“httpProtocol”=“%httpProtocol% “' – 2014-10-01 17:32:33

回答

3

作品与:

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

正是我所期待的:)。 – 2016-01-11 06:12:38