Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_smarty.inc.php on line 545

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_smarty.inc.php on line 545

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012
At some point in time you may find the need to get a list of all of the controllers within your application. It's actually quite simple so long as you don't need controllers from any plugins.

Place this code in any of your controllers and view it from the web (for instance, from the Users Controller): http://www.example.com/users/listControllers

You'll see something similar to the following:

The App::objects() method returns an array of objects of the given type, such as: 'model', 'controller', 'helper', or 'plugin' - it also accepts other parameters, such as "path" in case you do eventually need to check controllers for your plugins.

The array_diff() is there as a much simpler method to remove the AppController and PagesController from the returned results as they would most likely exist in your application regardless and aren't normally something you'd need to worry about with ACL as there are other means within Cake to handle access to them. You'll notice that array_diff doesn't return an array starting at index of 0 since it removes keys from the original array too. That shouldn't be a problem, but if it is you can always use a loop instead of array_diff() and just unset or splice the matching values.

I used the CakePHP convenience method of pr() (print_r surrounded by PRE tags), and a die() simply to show the returned results and print them to the screen. You'd probably prefer to double underscore the function name (__listControllers()) to make it a private method to the class (rather than publicly viewable via the web), and change pr() to return.

What's the purpose of this?
- Maybe you'd want to create a web interface for ACL and need to know which controllers to give/deny access to/from
- Maybe you want to create a navigation menu based on your controllers
...maybe you can think of something that I can't. :)

Alter to your own tastes. This is only a starting point.

Other useful links (check version compatibility in these resources):
Quick dessert: List all controllers of a CakePHP application
Automatically load all controllers and actions into ACO tables for ACL with a CakePHP Task
How to list all controllers

Trackbacks


Trackback specific URI for this entry

    Strict Standards: Only variables should be assigned by reference in /home/brendonk/mysiteonline.org/life/include/functions_smarty.inc.php on line 73
    No Trackbacks

Comments



    Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_comments.inc.php on line 292

    Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

    Strict Standards: Only variables should be assigned by reference in /home/brendonk/mysiteonline.org/life/include/functions_smarty.inc.php on line 73
    No comments

Add Comment


Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_smarty.inc.php on line 545

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

BBCode format allowed

   


Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/brendonk/mysiteonline.org/life/include/db/mysql.inc.php on line 270

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_config.inc.php on line 523

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Strict Standards: Non-static method serendipity_plugin_api::enum_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 956

Strict Standards: Non-static method serendipity_plugin_api::load_plugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 963

Strict Standards: Non-static method serendipity_plugin_api::probePlugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 542

Strict Standards: Non-static method serendipity_plugin_api::getClassByInstanceID() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 492

Strict Standards: Non-static method serendipity_plugin_api::includePlugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 497

Strict Standards: Declaration of serendipity_event_spartacus::event_hook() should be compatible with serendipity_event::event_hook($event, &$bag, &$eventData, $addData = NULL) in /home/brendonk/mysiteonline.org/life/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php on line 0

Strict Standards: Non-static method serendipity_plugin_api::get_plugin_title() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 967

Strict Standards: Non-static method serendipity_plugin_api::load_plugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 963

Strict Standards: Non-static method serendipity_plugin_api::probePlugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 542

Strict Standards: Non-static method serendipity_plugin_api::getClassByInstanceID() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 492

Strict Standards: Non-static method serendipity_plugin_api::includePlugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 497

Strict Standards: Declaration of serendipity_event_dpsyntaxhighlighter::event_hook() should be compatible with serendipity_event::event_hook($event, &$bag, &$eventData, $addData = NULL) in /home/brendonk/mysiteonline.org/life/plugins/serendipity_event_dpsyntaxhighlighter/serendipity_event_dpsyntaxhighlighter.php on line 0

Strict Standards: Non-static method serendipity_plugin_api::get_plugin_title() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 967

Strict Standards: Non-static method serendipity_plugin_api::load_plugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 963

Strict Standards: Non-static method serendipity_plugin_api::probePlugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 542

Strict Standards: Non-static method serendipity_plugin_api::getClassByInstanceID() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 492

Strict Standards: Non-static method serendipity_plugin_api::includePlugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 497

Strict Standards: Declaration of serendipity_event_nl2br::event_hook() should be compatible with serendipity_event::event_hook($event, &$bag, &$eventData, $addData = NULL) in /home/brendonk/mysiteonline.org/life/plugins/serendipity_event_nl2br/serendipity_event_nl2br.php on line 0

Strict Standards: Declaration of serendipity_event_nl2br::uninstall() should be compatible with serendipity_plugin::uninstall(&$propbag) in /home/brendonk/mysiteonline.org/life/plugins/serendipity_event_nl2br/serendipity_event_nl2br.php on line 0

Strict Standards: Non-static method serendipity_plugin_api::get_plugin_title() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 967

Strict Standards: Non-static method serendipity_plugin_api::load_plugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 963

Strict Standards: Non-static method serendipity_plugin_api::probePlugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 542

Strict Standards: Non-static method serendipity_plugin_api::getClassByInstanceID() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 492

Strict Standards: Non-static method serendipity_plugin_api::includePlugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 497

Strict Standards: Non-static method serendipity_plugin_api::get_plugin_title() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 967

Strict Standards: Non-static method serendipity_plugin_api::load_plugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 963

Strict Standards: Non-static method serendipity_plugin_api::probePlugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 542

Strict Standards: Non-static method serendipity_plugin_api::getClassByInstanceID() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 492

Strict Standards: Non-static method serendipity_plugin_api::includePlugin() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 497

Strict Standards: Declaration of serendipity_event_bbcode::event_hook() should be compatible with serendipity_event::event_hook($event, &$bag, &$eventData, $addData = NULL) in /home/brendonk/mysiteonline.org/life/plugins/serendipity_event_bbcode/serendipity_event_bbcode.php on line 0

Strict Standards: Declaration of serendipity_event_bbcode::uninstall() should be compatible with serendipity_plugin::uninstall(&$propbag) in /home/brendonk/mysiteonline.org/life/plugins/serendipity_event_bbcode/serendipity_event_bbcode.php on line 0

Strict Standards: Non-static method serendipity_plugin_api::get_plugin_title() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 967

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_config.inc.php on line 523

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/serendipity_config.inc.php on line 406

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/genpage.inc.php on line 32

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Strict Standards: Non-static method serendipity_plugin_api::count_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/genpage.inc.php on line 35

Strict Standards: Non-static method serendipity_plugin_api::count_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/genpage.inc.php on line 36

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_entries.inc.php on line 514

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_entries.inc.php on line 572

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_entries.inc.php on line 555

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_entries.inc.php on line 997

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_entries.inc.php on line 1086

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/brendonk/mysiteonline.org/life/plugins/serendipity_event_nl2br/serendipity_event_nl2br.php on line 114

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/brendonk/mysiteonline.org/life/plugins/serendipity_event_nl2br/serendipity_event_nl2br.php on line 114

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_entries.inc.php on line 1156

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_comments.inc.php on line 292

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012

Strict Standards: Only variables should be assigned by reference in /home/brendonk/mysiteonline.org/life/include/functions_smarty.inc.php on line 73

Strict Standards: Only variables should be assigned by reference in /home/brendonk/mysiteonline.org/life/include/functions_smarty.inc.php on line 73

Strict Standards: Only variables should be assigned by reference in /home/brendonk/mysiteonline.org/life/include/functions_smarty.inc.php on line 73

Strict Standards: Non-static method serendipity_plugin_api::hook_event() should not be called statically in /home/brendonk/mysiteonline.org/life/include/functions_smarty.inc.php on line 545

Strict Standards: Non-static method serendipity_plugin_api::get_event_plugins() should not be called statically in /home/brendonk/mysiteonline.org/life/include/plugin_api.inc.php on line 1012