I’ve asked a question here couple days ago, about how to avoid a function to be called from the browser. Some nice people pointed out that if put an underscore before de name of the function, it’ll only accept calls from inside app. But, by doing that, I cannot call the function from an element (by using requestAction). Is there another way to do it? Thanks!
Share
You can’t call a private or protected method from outside it’s class; (that’s the whole point of private and protected methods!)
Your only option, unless I’m mistaken, is to make the method public, or call it from within another method, perhaps with an ambiguous method name if you are worried about a user accidentally calling it.
You can also check to see if the request was made via
requestActionusing:So you could use this in a public method, and do the appropriate action depending on whether it was requested or not.