Welcome Guest, Not a member yet? Register   Sign In
Generate a list of all controllers and their methods
#1

[eluser]simshaun[/eluser]
Currently, I plan on creating a recursive function that goes through /application/controllers/, generating an array of class names and their methods. Methods whose name = the class name or begins with an underscore will be excluded.

Is there an easier way to do it than this?
#2

[eluser]jalalski[/eluser]
It's something I would normally use Doxygen for (doxygen.org). You can tell it to just document one folder or set of folders. Another is phpDoc (phpdoc.org) which does something similar.
#3

[eluser]simshaun[/eluser]
Thanks, but I should have elaborated on my question.

This is going to be so I can have dynamic controller/method permissions for users, without having to manually edit an array every time I make a new controller.
#4

[eluser]Rick Jolly[/eluser]
Have a look at the php tokenizer functions: http://php.net/manual/en/ref.tokenizer.php.

You can borrow ideas from many source code documentors or you can look at how amfphp finds methods it in this file: amfphp/core/shared/util/MethodTable.php.
#5

[eluser]helmutbjorg[/eluser]
Not sure if there is a function to list the classes that are initialised. Perhaps you could loop over the libraries or controllers directory and check if is in the list returned by get_included_files(). Then iterate over the matching objects methods using get_class_methods().

Or perhaps you could investigate the codeigniter object as i'm sure it will be listed in there somewhere. Do a print_r($this) on the codeigniter object and take a peek.

[edit]

I just read your post again. I thought i read that you only wanted the initialised classes.
#6

[eluser]GSV Sleeper Service[/eluser]
the 'reflection' API could help a lot. I've used the method you mentioned above in a project, but I'll be re-writing it to use the reflection tools at some point.
http://uk3.php.net/manual/en/language.oo...ctionclass
#7

[eluser]simshaun[/eluser]
Thanks for the help guys.
I think tokenizer is what I'm looking for.




Theme © iAndrew 2016 - Forum software by © MyBB