Reputation: 694
I'm starting a personnal blog with SF2 few days ago. I'm coding my back-end paying attention to reusability.
For this moment, i have 2 bundles : AdminBundle
and ArticleBundle
. I write some methods into ArticleBundle
like addAction
, listAction
, etc. This module also has its own routes (article/add, article/edit) defined in his routing.yml
When i'm in a part of my AdminBundle (ex : admin/article/add), I do this in AdminController
:
public function addAction() {
return $this->render('AdminBundle:Admin:add_article.html.twig');
}
and in my add_article.html.twig
:
{% block admin_content %} // Inheritance of admin view
{% render url('article_add') %} // article_add = article/add = route in ArticleBundle
{% endblock %}
This part works well but after the render all is managed by ArticleBundle
and my routing goes bad (ex : after my form submission routing is 'article/add' instead of 'admin/article/add').
So i don't know how to integrate this 2 bundles together keeping in mind that ArticleBundle
must be reusable.
thx
Upvotes: 0
Views: 330
Reputation: 17759
You could set out your actions within your ArticleBundle as services which are then referenced from within your Admin or other Bundle using (for example)
$form = $this->get('kero_zen.article_bundle.add_action.form');
$formHandler = $this->get('kero_zen.article_bundle.add_action.handler');
similar to that of the controllers in FOSUserBundle.
Upvotes: 1