0

I'm using the FOSRestBundle and would like to modify the routes it creates. I intend to add default parameters to each route the Rest Bundle creates. I've looked through the symfony docs on routing and have found nothing covering this use case.

If there is no way I would either have to

  • modify the FOS Rest Bundle directly

  • Or copy its route loader code, make my changes, and add it to my own bundle (and not use the Rest Bundle routing at all.)

I don't like either option.

Does Symfony offer a hook that allow for post processing of routes?

dlporter98
  • 1,590
  • 1
  • 12
  • 18

1 Answers1

2

FosRestBundle have a custom route loader. If you look in the github repository you will see that the routes are defined in the RestActionReader.php file. So the only solution is to override it and replace the class associate to the service fos_rest.routing.loader.reader.action

Fabien Salles
  • 1,101
  • 15
  • 24
  • 1
    Duh, I didn't even think about this approach. I'm going to try it out before accepting this as the answer. I the meantime, I have 1 upped the answer. – dlporter98 Oct 10 '17 at 14:14
  • This will work--thanks for the suggestion. The only difference is that I will override the fos_rest.routing.loader.yaml_collection service instead of teh one you mentioned. – dlporter98 Oct 10 '17 at 14:45