K
K
KOS_MOS2014-11-14 18:11:27
symfony
KOS_MOS, 2014-11-14 18:11:27

Is it possible to inherit routings in Symfony?

Here are two abstract routings:

route_one:
    pattern:  /r1
    defaults: { _controller: AcmeDemoBundle:Main:index, param1:1, param2:2, param3:3, param4:4}
  
route_two:
    pattern:  /r2
    defaults: { _controller: AcmeDemoBundle:Main:index, param1:1, param2:2, param3:3, param4:5}

As you can see, the second routing is identical to the first, except for the param4 value.
Why write all the parameters again? is it possible to call route_one from route_two and pass only the different param4 parameter?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2014-11-14
@shoomyst

You can use shared variables in php configs.
You can also try to separate similar routes into a separate class in annotations and set general parameters in class annotations, and define specific ones through method annotations.
Edit: For xml and yml one can try subcollections:
main.yml

_sub:
    resource: "@AcmeDemoBundle/Resources/config/sub.yml"
    prefix:   /
    defaults: { _controller: AcmeDemoBundle:Main:index, param1:1, param2:2, param3:3 }

sub.yml
route_one:
    pattern:  /r1
    defaults: { param4:4 }
  
route_two:
    pattern:  /r2
    defaults: { param4:5 }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question