Retreive routing parameters passed by url outside controller, symfony2

I am trying to access my slug parameters outside my controller.

I have a Routing YML like this:

adgroup:
    pattern:  /adgroup/{id}
    defaults: { _controller: ExampleBundle:AdGroup:index }
    requirements:
        id: \d+

..and a URL like this:

http://example.com/adgroup/25

I need a way to access the {id} variable without getting it from my controller, my controller is working perfectly. However, I am trying to build an Object that will rely heavily based on which Slugs are being passed in.

So far scouring the docs and many, many examples has left me no where.

What Ive tried:
I’ve var_dumped the entire Request::createFromGlobals method, and it’s children to see if its stored in there in anyway. It does not appear so.

Also, since I am on a development environment, the debug toolbar in symfony clearly shows Request: id: 25 in the profiler.

So the question is… How do I get my slugs / slug values from outside the controller?

I have way too many controllers to attempt to pass them in from there 1 by 1, and hacking it from exploding the URL is just a bad idea. :-)

I imagine there is some method I am unaware of to access these?

Leave a Reply

*

Hire Me
Follow Me!
Search
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.
Categories