Search code examples
symfonybundleextend

Symfony2: How to extend a Bundle?


If i have AlphaBunde that is parent of BetaBundle how can i extend a twig block without overriding the entire template?

How can i import the routes that exist only in BetaBundle?


Solution

  • You cannot extend a block in Twig. You can overload it if you extend a template (and call parent() which kind of works as inheritance).

    If you extend bundle you can overload its controllers or resources. I don't think you can really extend a template from a parent bundle because of how the paths are resolved. You can read more about it in the Extending a Bundle documentation chapter.

    Also, How to use Bundle Inheritance to Override parts of a Bundle might clarify few things.

    Remember to check Overriding Bundle Templates to learn how to overload templates in an application.

    About routes: I think you'll have to define each route in your application's configuration file if you want to import them selectively.