app = $app; } /** * Execute an action method in the module. * @param string name of the action to execute in the module * @return string output from the action */ public function execute($name) { // Stash the action name in the module $this->action_name = $name; // Call the module's preExecute, which may modify the action name $this->preExecute(); // If a method for the action doesn't exist, resort to the default. $method_name = "execute".$this->action_name; if (!method_exists($this, $method_name)) { $method_name = 'executeDefault'; } // Call the module's action method. $this->output = $this->$method_name(); // Call the module's postExecute, which may modify the final output. $this->postExecute(); // At last, return the output. return $this->output; } /** * Method called before each action. May modify $this->action_name to * change the action just before execution. */ public function preExecute() { } /** * Method called after each action. May modify $this->output to change the * action's output just after execution. */ public function postExecute() { } /** * Default action for the module. */ public function executeDefault() { echo "ACTION MODULE DEFAULT"; } }