i have two different actions in two different modules, and i need to execute one of them inside the other.
consider the following actions:
//first module
class module1Actions extends sfActions {
protected function function1Form(sfWebRequest $request, sfForm $form) {
//i need to call a function from module2 in here to do sth but i don't need any view to be returned.
//but i need some variables to be returned by the second action
}
}
//second module
class module2Actions extends sfActions {
protected function executeSth(sfWebRequest $request, sfForm $form) {
//Do Something in here and return some values.
}
}
as i said i need to execute an action and get some values from it but i don't know how to call it. it's in a different module . can i access it ? how? and how i get the values back?
thanks.
Depending on how you get those values, these are the best paths:
If you get them via operations on a record or a table, move the code into the model layer, and call that from both your actions
If you get them some other way (like processing user input), create a utility class in your lib
folder, and add it there as function, and call that from both your actions
This way you prevent code duplication, and still don't break the MVC separation of concerns.