For CakePHP 2.3.8
How can I call Another Controller function in CronController.php
Any ideas?
Below is the code:
App::import('Controller', 'Products'); // mention at top
// Instantiation // mention within cron function
$Products = new ProductsController;
// Call a method from
$Products->ControllerFunction();
Hope it helps some one !
I referenced the manual to find a solution to this.
public function that_controller_function_you_are_writing () {
# this is cakes way of running required
App::import('Controller', 'Users');
$UsersController = new UsersController;
# now you can reference your controller like any other PHP class
$UsersController->that_function_you_needed();
}
This is the link: http://book.cakephp.org/2.0/en/core-utility-libraries/app.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With