I am developing a small CMS for my company using Symfony2. I really like this framework. I like class classes and their reuse (which is all about forms after all).
But (yes, there is a "but"). I feel like doing the same thing, copy and paste all the controllers . The coding we hate. When all the business logic has moved to Services , as well as forms, events, actions in action in Doctrine, all my controllers do the same:
- Get repository
$this->get('mycompany.repository.entity') - Dynamically create a form (logic inside the form class itself)
- Validate form, return view or save object
- etc.
I mean, controller actions are all the same , just a few characters.
How can there be DRY with Symfony2 in my controllers? Maybe the dispatcher as a service (a concept that I discovered just a few days ago) can help?
EDIT : related question (to the first idea proposed by Boo): Symfony2 how to redirect to an action without a hard drive routing name?
gremo source
share