I need to use a controller functions inside my another controller. But I don't want to make
$Myother = new MyotherController();
every time I use a method from that controller. How can I initialize a controller so I won't make a "new" in every method ?
I found this, It writes like this:
App::import('Controller', 'Pages');
class UsersController extends AppController {
var $Pages;
function beforeFilter() {
$this->Pages =& new PagesController; /*Loads the class*/
$this->Pages->constructClasses(); /*Loads the model associations, components, etc. of the Pages controller*/
}
function index() {
$this->Pages->index();
}
}
Is this the proper way, or is there a better way ?