How do I get a list of all functions inside a controller in cakephp

不问归期 提交于 2019-12-04 01:26:23

Something like this should do the trick: https://github.com/dereuromark/cakephp-sandbox/blob/master/Plugin/Sandbox/Controller/SandboxAppController.php#L12

It basically uses a very basic PHP function:

$actions = get_class_methods($Controller);

Then get parent methods:

$parentMethods = get_class_methods(get_parent_class($Controller));

Finally, using array_diff you get the actual actions in that controller:

$actions = array_diff($actions, $parentMethods);

Then you can still filter out unwanted actions.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!