CakePHP,在另一个控制器内导入一个控制器

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 ?

I think really the only way to go is to switch to using some components. Initializing new controllers with their components / helpers / models, will cause much more over head, which might not be worth the trade off. Let alone, It'll promote bad design.

My advice, is to go with components.

You can always use requestAction() if you need just the result of an action in another controller. However, even CakePHP say people should be careful with it.

"If used without caching requestAction can lead to poor performance. It is rarely appropriate to use in a controller or model."

You should try adding these common methods to your AppController, since all controllers extend AppController it's a great place to stick common controller functionality.

That being said, if you're loading all the models and associations of one controller into another, then you might be better off moving the associated code into the appropriate model instead.