Reputation: 477
In a lot of my Cake apps I have shells which are invoked via cron and the cake console, and I am wondering if I can restrict these methods in a "private" manner so that they can be ONLY invoked by the console? For example, let's say I have this in my shell:
$this->requestAction(array('controller' => 'reviews', 'action' => 'generateReports'));
How could I restrict the "generateReports" action to be a "shell only" method? Because I could also invoke the method in my browser by going to:
http://site.url/reviews/generateReports
And as useful as this may be for debugging it could be dangerous in a production environment.
If I make the method private, i.e. _generateReports, then the shell will not be allowed to execute it. Any ideas? I feel like there should be an easy solution to this but I haven't been able to find one, or a similar question posted. Thanks!
Upvotes: 1
Views: 478
Reputation: 975
If your action is only to be executed by the server, then why build out the action inside of a web accessible controller?
If you wish for only the CakeShell to run that method then the action should only be created as a CakeTask.
Upvotes: 1