Example #1
0
 /**
  * Returns an array of all possible models within the system.
  */
 private static function _getModels()
 {
     if (is_null(self::$_models)) {
         self::$_models = array();
         $paths = Load::getModulePaths();
         foreach ($paths as $path) {
             $modules = scandir($path);
             foreach ($modules as $module) {
                 if ($module[0] == '.') {
                     continue;
                 }
                 $modelsPath = sprintf('%s%s/models/', $path, $module);
                 if (file_exists($modelsPath)) {
                     $models = scandir($modelsPath);
                     foreach ($models as $model) {
                         if ($model[0] == '.') {
                             continue;
                         }
                         $class = sprintf('%s_%sModel', ucfirst($module), ucfirst(str_replace(EXT, '', $model)));
                         if (!in_array($class, self::$_models)) {
                             self::$_models[] = $class;
                         }
                     }
                 }
             }
         }
     }
     return self::$_models;
 }
Example #2
0
 /**
  * Allows database install, update, seed and optimize commands to be run
  * through the URL instead of forcing people to use the CLI.
  *
  * The config "db.enabled_url_runner" must be set to "true" to allow running
  * commands otherwise 404 will be returned.
  *
  * The "db.enable_url_runner" command should be set to "false" in a production
  * environment.
  */
 public static function runner($cmd, $force = false)
 {
     $force = $force == 'force' ? true : false;
     if (Config::get('db.enable_url_runner')) {
         switch ($cmd) {
             case 'install':
                 Db_Runner::install($force);
                 break;
             case 'update':
                 Db_Runner::update();
                 break;
             case 'seed':
                 Db_Runner::seed();
                 break;
             case 'optimize':
                 Db_Runner::optimize();
                 break;
             default:
                 die('Invalid command. Must be install, update ,seed or optimize.');
         }
         exit;
     } else {
         return ERROR_404;
     }
 }