1
I’m trying to get all the methods/actions of all the controllers from my Cakephp application.
Turns out I can’t bring the methods of all controllers and I don’t understand why.
I tried to import App::import
and with App::uses
, but the get_class_methods()
does not return the methods/actions of all.
Follow what I created:
//Pega a lista de controllers da aplicação e adiciona num array;
$controllersApp = App::objects('controller');
//Varre o array de controllers da aplicação e adiciona cada item num array global
foreach($controllersApp as $c)
{
$temp_listControllers[] = $c;
}
//Pega a lista de plugins
$plugins = App::objects('plugin');
//Varre o array de plugins
foreach($plugins as $plugin)
{
//Cria string para pegar lista de Controllers de cada Plugin: Plugin.controller
$p = $plugin.'.controller';
//Pega lista de controllers do Plugin corrente em $plugin
$lista = App::objects($p);
//Varre o array de controllers do Plugin corrente e adiciona cada item no array global
foreach($lista as $l)
{
$temp_listControllers[] = $l;
}
}
foreach($temp_listControllers as $c)
{
//$r = str_replace("Controller", "", $c);
$listControllers[] = $c;
}
foreach($listControllers as $controller)
{
$actions = get_class_methods($controller);
echo "<hr /><h1>".$controller."</h1>";
pr($actions);
}
Am I doing something wrong? Is there any other way to do it?
I have no way to test this method at the moment, but I hope I can help.
– Guilherme
So I’m using a 2.3.1 version of Cakephp. I happened to check the Cakephp documentation and did not find the Class Configure getInstance method in any version. Gives the following error when running: Error: Call to Undefined method Configure::getInstance()
– morphinduction