CodeIgniter Forums

Full Version: Any way to return all controllers in an application?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Solarpitch[/eluser]
Hi Guys,

just wondering id there is any way I can do something to get all the controllers and pages within an application?

I want to return a list off all the main pages to the user to which he/she can then select what pages they want to have access to and I can go about creating a permissions table for that.

For example:

Dashboard
- view client
- client list
etc

Orders
- new order
- view orders
etc

Then the user can say, ok I need access to the whole dashboard or just the client list etc. Hope this makes sense.

El Forum

[eluser]BrianDHall[/eluser]
Sort of yes, sort of no. I guess it would be considered 'non-trivial'.

You would need to build a function that would go through all the files in the controllers folder and look through them, and be sure to use the nomenclature of the sort that if a function begins with _ then it isn't really a page.

Out of the box CI only accesses the one requested controller and function called for by your routing.

I believe this topic is considered 'reflection' for the controller that is loaded, and class/function navigating for the files not loaded. I have intentionally avoided any need to do anything like this as it is a bit of a can of worms, so I can't offer much advice further.

It's one of those 'fun' sorts of projects though like building a REST server in PHP - plenty of people do it, its just I generally find it a lot of work without much bang for the buck.

You might check on code or class navigation in PHP to see some ways to go about it.

El Forum

[eluser]renownedmedia[/eluser]
[quote author="BrianDHall" date="1254867066"]You would need to build a function that would go through all the files in the controllers folder and look through them, and be sure to use the nomenclature of the sort that if a function begins with _ then it isn't really a page.[/quote]

OMG, you're the only person I know other than myself to use the word nomenclature outside the realm of science!

El Forum

[eluser]BrianDHall[/eluser]
[quote author="Thomas Hunter" date="1254868697"][quote author="BrianDHall" date="1254867066"]You would need to build a function that would go through all the files in the controllers folder and look through them, and be sure to use the nomenclature of the sort that if a function begins with _ then it isn't really a page.[/quote]

OMG, you're the only person I know other than myself to use the word nomenclature outside the realm of science![/quote]

Wow...I didn't even realize I used it! I somehow even managed to use it correctly, no less. Huzzah. Like the man says, never use a big word when a diminutive one will suffice Wink

One thing I've kept from pondering logic, philosophy, and technical lingo is an appreciation for the beauty of precision - there are few things so pleasing as a word that can convey just precisely what you mean...even if occasionally inciting a run on the Wikipedia.

-My mind is a raging torrent, flooded with rivulets of thought, cascading into a waterfall of creative alternatives. -Gal-darnit, Mr. Lamarr, you use your tongue prettier than a 20-dollar whore.