Php 包括其他模块的模块

Php 包括其他模块的模块,php,symfony1,symfony-1.4,Php,Symfony1,Symfony 1.4,我有: 总之,一切都是好消息。我想包括模块EditNews的executeEdit和EditSuccess。我想复制所有的功能和模板。 我怎样才能做到我不想要复制文件。我想要一些东西,如include\u partial或renderTemplate?有可能吗? 我使用Symfony 1.4.13事实上: modules: News action: executeIndex executeEdit etc. templates: _editPlus.ph

我有:

总之,一切都是好消息。我想包括模块EditNews的executeEdit和EditSuccess。我想复制所有的功能和模板。 我怎样才能做到我不想要复制文件。我想要一些东西,如include\u partial或renderTemplate?有可能吗? 我使用Symfony 1.4.13

事实上:

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

modules: EditNews
      action:
      ...
      templates:
       ...
这可能也与您有关:

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

你正在说明为什么精益行动和肥胖模式很重要。您应该将大部分逻辑移到模型或其他外部类中,特别是当您要在不同的操作中重用该代码时。通过这种方式,您应该能够将操作中的代码量减少到只有几行,同时跨不同的操作维护一个公共的代码库是很简单的


最后,您似乎需要两个独立的操作,因此您要么复制代码并在不同的地方维护代码(=糟糕的做法),要么按照我的建议进行重构。

我希望呈现executeEdit和EditSuccess以获得其他执行和其他成功。我不需要重复代码。如果两个操作都相同,为什么您需要在模块EditNews中有一个额外的操作?我没有重复代码,如果我先添加更改,然后我希望在第二个中自动更改如果它们应该相同并且保持相同,为什么还要创建第二个操作?重用单个操作有什么问题?我想在executeEdit和EditSuccess(模块二)中使用executeEdit和EditSuccess(模块新闻)
return 'Finish'; // in your action will use ActionnameFinish.php as template