在我的Symfony 2.8项目中,我有一个路由文件:
...
foo_common_routing:
resource: "@FooBundle/Resources/config/routing/foo-common-routing.yml"
prefix: /
condition: "false == request.cookies.has('bar')"
...
在foo-common-routing.yml
:
route_foo:
path: /foo
defaults:
_controller: FooBundle:Foo:foo
route_bar:
path: /bar
defaults:
_controller: FooBundle:Foo:bar
route_baz:
path: /baz
defaults:
_controller: FooBundle:Foo:baz
如何route_baz
忽略条件"false == request.cookies.has('bar')"
?
到目前为止,我已经尝试过:
(1)
route_baz:
path: /baz
defaults:
_controller: FooBundle:Foo:baz
condition: null
(2)
route_baz:
path: /baz
defaults:
_controller: FooBundle:Foo:baz
condition: ''
但上述情况似乎都没有效果。
答案 0 :(得分:1)
你不能这样做,你需要的是没有条件的第二个路由文件。将 route_baz 放在第二个文件中。
...
foo_common_routing:
resource: "@FooBundle/Resources/config/routing/foo-common-routing.yml"
prefix: /
condition: "false == request.cookies.has('bar')"
another_foo_common_routing:
resource: "@FooBundle/Resources/config/routing/another-foo-common-routing.yml"
prefix: /
...