我有两个捆绑包A和B,在B中我需要重写A的模板,所以我使用了bundle inheritence。 目前为止一切正常,但现在我只需要在某些特定情况下覆盖包A的模板。我在包B的动作(将覆盖束A的动作)尝试这样做:在特定情况下覆盖模板和控制器
class ArticleController extends BaseArticleController
{
public function detailsAction(Request $request, $article)
{
if('general' === $article->getType()) {
// this doesn't return the template of the bundle A :(
return parent::detailsAction($request, $article);
}
// else go on on rendering the other template...
}
但这覆盖不管怎样,即使我的文章的类型是'general'
它返回捆B的模板
这正是我所做的,但它是呈现B的模板,因为它具有与包A中相同的名称。我发布了我相信一个很好的解决方案 – smarber 2014-10-08 08:41:38