Exemplo n.º 1
0
 /**
  * Get list of available controllers
  */
 public function controllersAction()
 {
     $appPath = $this->_configMain['application_path'];
     $folders = File::scanFiles($this->_configMain['backend_controllers'], false, true, File::Dirs_Only);
     $data = array();
     $systemControllers = $this->_configBackend->get('system_controllers');
     if (!empty($folders)) {
         foreach ($folders as $item) {
             $name = basename($item);
             /*
              * Skip system controller
              */
             if (in_array($name, $systemControllers, true)) {
                 continue;
             }
             if (file_exists($item . '/Controller.php')) {
                 $name = str_replace($appPath, '', $item . '/Controller.php');
                 $name = Utils::classFromPath($name);
                 $data[] = array('id' => $name, 'title' => $name);
             }
         }
     }
     if ($this->_configMain->get('allow_externals')) {
         $config = Config::factory(Config::File_Array, $this->_configMain->get('configs') . 'externals.php');
         $eExpert = new Externals_Expert($this->_configMain, $config);
         $extControllers = $eExpert->getBackendControllers();
         if (!empty($extControllers)) {
             $data = array_merge($data, array_values($extControllers));
         }
     }
     Response::jsonSuccess($data);
 }