【发布时间】:2010-02-25 12:36:44
【问题描述】:
我有一个组件已经愉快地构建和呈现菜单有一段时间了。现在我必须提供一个共享所有相同逻辑的特殊情况,但需要在已经存在的情况之前进行一些工作。我想要做的是创建一个新的组件操作,它将执行必要的预处理,将共享逻辑放在完成计算方面,然后通过现有的模板部分进行渲染(当一切都说完了,它仍然是一个菜单,如任何其他的——构建它只需要更多的工作)。
很遗憾,我找不到任何方法。
这是我现在拥有的高级文件/代码细分:
#
# navigation/actions/components.class.php
#
public function executeMenu() {
/**
* This method runs most of the menus and does most of the work
* that's required of the special case.
*
* Once complete, of course, it renders through navigation/templates/_menu.php
*/
}
public function executeSpecialMenu() {
/**
* Do some preparatory work and delegate to executeMenu()
* to finish up and render the menu. I'd like this action
* to render through the _menu.php partial as well.
*/
}
#
# templates/layout.php
#
<?php include_component( 'navigation', 'menu', array( 'menu' => 'Entity Type' ) ) ?>
/** SNIP */
<?php include_component( 'navigation', 'SpecialMenu' ) ?>
任何意见将不胜感激。
【问题讨论】:
标签: symfony1