-1

how to programmitcally list of all module and all controllers and actions for each module?

thanks

user1400
  • 1,411
  • 4
  • 26
  • 36
  • 2
    http://stackoverflow.com/questions/887947/get-all-modules-controllers-and-actions-from-a-zend-framework-application – Haim Evgi Nov 23 '10 at 09:20

1 Answers1

3
   $front = $this->getFrontController();
    $acl = array();

    foreach ($front->getControllerDirectory() as $module => $path) {

            foreach (scandir($path) as $file) {

                    if (strstr($file, "Controller.php") !== false) {

                            include_once $path . DIRECTORY_SEPARATOR . $file;

                            foreach (get_declared_classes() as $class) {

                                    if (is_subclass_of($class, 'Zend_Controller_Action')) {

                                            $controller = strtolower(substr($class, 0, strpos($class, "Controller")));
                                            $actions = array();

                                            foreach (get_class_methods($class) as $action) {

                                                    if (strstr($action, "Action") !== false) {
                                                            $actions[] = $action;
                                                    }
                                            }
                                    }
                            }

                            $acl[$module][$controller] = $actions;
                    }
            }
    }
animuson
  • 53,861
  • 28
  • 137
  • 147
Mogg
  • 31
  • 2