I have a blog which generates URLs like:
/article-name
/my-article
/other-article
Then there is a forum with threads using URLs like:
/thread-name
/my-thread
/what-do-you-think
How can I make router to handle this situation? I don’t want to use any more URL parameters (like /blog/article-name and /forum/thread-name). Best way would be first asking blog controller whether there is an article with this URL and if doesn’t, ask the forum controller. But how?
You have to define your event listener.
Then, in your
RequestListeneryou should defineonKernelRequest()method and put there your route handling, such asFor additional information about event listeners you could refer to the documenation:
http://symfony.com/doc/current/cookbook/service_container/event_listener.html
http://symfony.com/doc/2.0/cookbook/doctrine/event_listeners_subscribers.html