include modules for other modules
I have:
modules: News
action:
execute开发者_Python百科Index
executeEdit
etc.
templates:
_editPlus.php
IndexSuccess.php
EditSuccess.php
modules: EditNews
action:
...
templates:
...
In modules News all is good. I would like include executeEdit and EditSuccess for modules EditNews. I would like copy all functionality and template. How can i make it? I dont want copy files. I would like somethings like include_partial or renderTemplate ? Is possible? I use Symfony 1.4.13
Indeed it is:
return $this->renderPartial('partialname'); // renders you _partial.php
return $this->renderText('foobar'); // will only render you 'foobar'
and this might be also relevant for you:
return 'Finish'; // in your action will use ActionnameFinish.php as template
You are illustrating why it is important to have lean actions and fat models. You should move most of your logic to your models or other external classes, especially if you are going to reuse that code in different actions. That way you should be able to reduce the amount of code in your actions to only a few lines, at it will be trivial to maintain a common codebase across different actions.
In the end it seems like you will be needing two seperate actions though, so either you do copy the code and go through the trouble of maintaining it in different places (=bad practice), or you refactor it like I suggested.
精彩评论