Symfony2:如何扩展捆绑包? [英] Symfony2: How to extend a Bundle?

查看:52
本文介绍了Symfony2:如何扩展捆绑包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有 AlphaBunde BetaBundle 的父级,如何在不覆盖整个模板的情况下扩展细枝块?

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

如何导入仅在 BetaBundle 中存在的路由?

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

推荐答案

您不能在Twig中扩展块。如果扩展模板,则可以重载它(并调用parent()作为继承来工作)。

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).

如果扩展bundle,则可以重载其控制器或资源。我认为您真的不能从父捆绑扩展模板,因为它们是如何解析路径的。您可以在扩展捆绑包中了解更多信息。文档章节。

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.

这篇关于Symfony2:如何扩展捆绑包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆