包括其他模块的模块


include modules for other modules

我有:

modules: News 
  action:
    executeIndex
    executeEdit
    etc.
  templates:
    _editPlus.php
    IndexSuccess.php
    EditSuccess.php
modules: EditNews
      action:
      ...
      templates:
       ...

模块新闻都是好的。我想包括executeEdit和EditSuccess模块EditNews。我想复制所有的功能和模板。我怎样才能做到呢?我不想复制文件。我想要一些像include_partial或renderTemplate ?是可能的吗?我使用Symfony 1.4.13

确实如此:

return $this->renderPartial('partialname'); // renders you _partial.php
return $this->renderText('foobar'); // will only render you 'foobar'

,这可能也与你相关:

return 'Finish'; // in your action will use ActionnameFinish.php as template

你正在说明为什么瘦模特和胖模特很重要。您应该将大部分逻辑移到模型或其他外部类中,特别是如果您打算在不同的操作中重用该代码。这样,您应该能够将操作中的代码量减少到只有几行,因为在不同的操作中维护公共代码库将是微不足道的。

最后,你似乎需要两个单独的操作,所以你要么复制代码,然后在不同的地方维护它(=糟糕的做法),要么像我建议的那样重构它。