开发者

Symfony 2.0 - routing

How can I set up routing in symfony to be like that(if one rule won't work, next should be grabbed):

  • /controller/action/param/param/param/...
  • /admin/controller/action/param/param/param/... ("admin" is constant here - name of the bundle)

I tried that:

homepage:
  pattern:  /
  defaults: { _bundle: HelloBundle, _controller: Hello, _action: i开发者_运维技巧ndex }
default:
  pattern: /:controller/:action/*
  defaults: { _bundle: HelloBundle }

But it doesn't work, even for the first rule. Sorry for my English, and thanks for any future help ;>.


Hmmm... I didn't use sf2.0 yet but something like that should works:

homepage:
  pattern:  /
  defaults: { ... }

admin_default:
  pattern:  /admin/:controller/:action/*
  defaults: { _bundle: AdminBundle }

default:
  pattern:  /:controller/:action/*
  defaults: { _bundle: HelloBundle }


as read in the doc ( http://symfony-reloaded.org/quick-tour/part-3 ):

# src/Application/HelloBundle/Resources/config/routing.yml
hello:
    pattern:  /hello/:name
    defaults: { _controller: HelloBundle:Hello:index, _format: xml }

So your routing.yml could look like:

homepage:
  pattern:  /
  defaults: { _controller: HelloBundle:Hello:index }
default:
  pattern: /:_controller/*
  defaults: { _controller: HelloBundle:Hello:myaction }
default_admin:
  pattern: /admin/:_controller/*
  defaults: { _controller: HelloBundle:Hello:myAction }

But I don't know if it works....

Please inform me if it works !

Florian.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜