[eluser]trice22[/eluser]
Hello,
there are probably better and easier ways to handle, what I’ve here, but I needed this library for a project and thought I share it and get some opinions:
What does it do?
It “collects” all controllers in a certain folder-scope and pushes them into an array. It also “scans” these controllers and pushes the methods, each controller contains into the same array. Thereby all private functions, functions, that start with a pre-defined identifier (default: “__"), the constructors as well as methods that are being inherited by the Controller-class are being left out.
Example:
Controller1:
Code:
class Controller1 extends Controller {
function Controller1()
{
parent::Controller();
}
function function1()
{
//…
}
function function2()
{
//…
}
function __function3()
{
//…
}
}
Controller2:
Code:
class Controller2 extends Controller {
function Controller2()
{
parent::Controller();
}
function function1()
{
//…
}
private function function2()
{
//…
}
}
will result in this array:
Code:
Array (
[0] => Array (
[controller] => controller1
[methods] => Array (
[0] => function1
[1] => function2 )
)
[1] => Array (
[controller] => controller2
[methods] => Array (
[0] => function1 )
)
)
How to use it?
Copy “Struct.php” into you library-folder.
In your Model or Controller:
Code:
$this->load->library('Struct');
$structure_array = $this->struct->getArray();
// Optional: Set different folder-scope (default: 'controllers/' )
$this->struct->setScope('controllers/navigation/');
// Optional: Set identifier for methods, that should not be included (default: '__' )
$this->struct-> setPrivId('exclude_this_');
Why?
I’m thinking about using it e.g for automated navigation-generation.