+88 01797-506292

Post Date: October 23, 2017
Posted By: admin

How to get all classes and methods

public function getControllers() {

        $controllers = App::objects('controller');
        $new_controllers = array();
        foreach ($controllers as $controller) {
            if ($controller != 'AppController') {
                // Load the controller
                App::import('Controller', str_replace('Controller', '', $controller));

                // Load its methods / actions
                $actions = get_class_methods($controller);

                foreach ($actions as $idx => $method) {

                    if ($method{0} == '_') {
                        unset($actions[$idx]);
                    }
                }

                $new_controllers[$controller] = $actions;
            }
        }

        pr($new_controllers);
    }

Leave a Reply

Your email address will not be published. Required fields are marked *