Welcome Guest, Not a member yet? Register   Sign In
Best methods to control helper functions
#1

[eluser]sjmiller85[/eluser]
I'm looking to better understand best practices when dealing with controlling access to little "mini-helper" functions within my controllers.

Let's use an example of a function which you use as a generic database query function. By itself, if you were to access this function via your browser, it wouldn't return anything to the screen, thus common sense would dictate that you don't want it to be accessible via a browser. You could do generic checks in each and every one of these functions to route the user to a different function if it were attempted, but that gets tedious.

What is the best way to control access to prevent users from accessing these little mini-helpers I've developed within my controllers, or am I going about this all wrong, and should I do it another way?

I am currently running php v5.2.13
#2

[eluser]yohanip[/eluser]
Hi, to make the controller private and could not be accessed by the public you need to add an extra "_" on your functions declaration such as this :
Code:
<?php
class SomeClass extends Controller
{
function SomeClass()
{
}
//this should be private
function _a_private_function($a = 100, $b = 100)
{
//.....declarations
}
}
#3

[eluser]InsiteFX[/eluser]
Make a MY_Controller and Extend your Controllers from the MY_controller
this way you only need to write it once.

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB