Reputation: 2473
I want a shell script I've got to be able to access appController, is this possible, without copying that code into the AppShell ? If so any pointers ?
Thanks in advance
Upvotes: 1
Views: 2391
Reputation: 29007
In general, shells shouldn't rely on code inside a controller, some pointers (as requested):
If the above options really aren't an option, you will have to manually initialise the AppController. keep in mind that, because you're running from the command line, various things will not be present, e.g. There will be no 'request' and some environment variables (e.g. host name) may not return the expected value!
Manually initialising the controller will be something like this;
App::uses('CakeRequest', 'Network');
App::uses('CakeResponse', 'Network');
App::uses('Controller', 'Controller');
App::uses('AppController', 'Controller');
// request/response may be optional, depends on your use
$controller = new AppController(new CakeRequest(), new CakeResponse());
$controller->constructClasses();
$controller->startupProcess();
Upvotes: 4