So im writing this permissions library that is based on class=>method restriction
aka: artificial crud, if you make each function have a specific function
Heres what I have right now.
It works however I have to manually tell it was to ignore. in other words it takes everything that I don't flag.
I want to incorporate the ReflectionClass from PHP however it has very little documentation (more like none) So I have no idea where to begin.
I am not set on the reflection class if there is a better/easier way to do this.
Basically what I want to do is load a class and grab all public methods.
and to ignore the rest of them.
Any help is appreciated.
aka: artificial crud, if you make each function have a specific function
Heres what I have right now.
It works however I have to manually tell it was to ignore. in other words it takes everything that I don't flag.
Code:
/**
* Auto Generate Permissions
* Generates all the systems permissions by reading the controller directory
* and loading the files to get their methods
*/
function auto_generate_permission()
{
// Open the Application Directory
$directory = opendir($this->APPLICATION_DIRECTORY);
// loop through all the files and set the name into an array
while (($file = readdir($directory)) !== FALSE)
{
if (preg_match('/.php/i',$file))
{
$temp = explode('.',$file);
$controllers[] = $temp[0];
}
}
// Close the Application Directory
closedir($directory);
// Look through all the controllers for their methods
foreach ($controllers as $c)
{
// Check to see if the class has been loaded
if (!class_exists($c))
{
$this->CI->load->file($this->APPLICATION_DIRECTORY.$c.'.php');
}
// Add the constructors to the values we don't care about
$this->invalid_methods[] = ucfirst($c);
foreach (get_class_methods($c) as $key => $val)
{
// Put the methods we care about into an array
if (!in_array($val,$this->invalid_methods))
{
$method[$c][] = $val;
}
}
// Now lets create the classes and methods and relate them
foreach ($method as $class => $methods)
{
foreach ($methods as $value)
{
$this->permission($class,$value,FALSE);
}
}
}
}
I want to incorporate the ReflectionClass from PHP however it has very little documentation (more like none) So I have no idea where to begin.
I am not set on the reflection class if there is a better/easier way to do this.
Basically what I want to do is load a class and grab all public methods.
and to ignore the rest of them.
Any help is appreciated.