문제

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!

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top