Advertisement
Guest User

get actions from controller in cakephp

a guest
Jan 29th, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. public function _getControllerActions($controller)
  2.     {
  3.         $controller = explode('/', $controller);
  4.         $appController = (count($controller) > 1? $controller[0] . 'AppController': 'AppController');
  5.         $plugin        = (count($controller) > 1? $controller[0] . '.': '');
  6.         $controller    = (count($controller) > 1? $controller[1]: $controller[0]);
  7.  
  8.         App::uses($controller . 'Controller', $plugin . 'Controller');
  9.         App::uses($appController, $plugin . 'Controller');
  10.  
  11.             $methods        = get_class_methods($controller . 'Controller');
  12.         $defaultMethods = get_class_methods($appController);
  13.  
  14.         if ($methods == null) {
  15.             return array();
  16.         }
  17.  
  18.         if (is_array($defaultMethods)) {
  19.             $methods = array_diff($methods, $defaultMethods);
  20.         }
  21.  
  22.             foreach ($methods as $k => $v) {
  23.                     if ($v{0} == '_') {
  24.                         unset($methods[$k]);
  25.                     }
  26.             }
  27.  
  28.         return array_values($methods);
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement