D
D
Dmitry Khaperets2014-08-25 00:02:15
symfony
Dmitry Khaperets, 2014-08-25 00:02:15

What is the correct way to merge routing rules in Symfony2?

There are two rules:

records:
    path: /records
    defaults: { _controller: SomeBundle:Index:index, page: 1 }

records_page:
    path: /records/page/{page}
    defaults: { _controller: SomeBundle:Index:index }
    requirements:
        page: \d+

When going to pages:
/records - get records for the first page
/records/page/2 - get records for the second page
/records/page/3 - get records for the third page
....
How can the above rules be combined so that when when following the same links (/records, /records/page/2, /records/page/3) the same conditions were met?
PS. I was thinking of doing something like this:
records:
    path: /records(/page/{page})?
    defaults: { _controller: SomeBundle:Index:index, page: 1 }
    requirements:
        page: \d+

But it doesn't work(

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2014-08-25
@Khaperets

Until this pull request is accepted, one round will not work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question