public static function factory($id = 'core', $command = '', $args = array()) { $module = new KurogoAPIModule(); $module->init($command, $args); return $module; }
$parts = explode('/', ltrim($path, '/'), 2); if ($parts[0] == API_URL_PREFIX) { if (Kurogo::getSiteVar('PRODUCTION_ERROR_HANDLER_ENABLED')) { set_exception_handler("exceptionHandlerForProductionAPI"); } else { set_exception_handler("exceptionHandlerForAPI"); } $parts = explode('/', ltrim($path, '/')); switch (count($parts)) { case 1: throw new KurogoUserException("Invalid API request: '{$_SERVER['REQUEST_URI']}'", 1); case 2: $id = 'kurogo'; $command = $parts[1]; $Kurogo->setRequest($id, $command, $args); if (!($module = KurogoAPIModule::factory($id, $command, $args))) { throw new KurogoException("Module {$id} cannot be loaded"); } break; case 3: $id = isset($parts[1]) ? $parts[1] : ''; $command = isset($parts[2]) ? $parts[2] : ''; $Kurogo->setRequest($id, $command, $args); if (!($module = APIModule::factory($id, $command, $args))) { throw new KurogoException("Module {$id} cannot be loaded"); } break; default: throw new KurogoUserException("Invalid API request: '{$_SERVER['REQUEST_URI']}'", 1); break; }