[eluser]tokyotech[/eluser]
How do I get one controller to call a method from another controller? Is it considered bad practice if I have to resort to doing this? Let me explain why I need to do this. I have this ControllerB which has a methodB() which I'd like to use both from JS land and PHP land.
Code:
class ControllerB extends Controller {
public function methodB() {
session_start();
$_SESSION['sessionB'] = 'i am set';
}
}
JS can call it through AJAX:
Code:
[removed]
new Ajax.Request(
'index.php/controllerB/methodB'
);
[removed]
But it's also useful in PHP land for controllerA to call controllerB/methodB:
Code:
class ControllerA extends Controller {
public function methodA() {
//psuedocode which I don't know how to do:
$this->load->controller('controllerB');
$this->controllerB->methodB();
}
}