CakePHP: restrict controller method to shell only?
In a lot of my Cake apps I have shells which are invoked via cron and the cake console, and I am wonder开发者_运维问答ing 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
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!
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.
精彩评论