CakePHP: Calling Function From Other Controller


Import Controller of the function you want to use.

Once you imported  the controller you can call any function of this controller.
<?php
  //Import controller
  App::import('Controller', 'SmsOutgoings');

  class ReportsController extends AppController {
    
    public function add() {

         $message = "Notification: New report submitted!";

       //Instantiation
        $SmsOutgoings= new SmsOutgoingsController;
      //Call a method from SmsOutgoingsControllerwith parameter
      $SmsOutgoings->notify_user($user_id, $message); 
    }
  }
?>

Comments