/** * アプリケーションのコントローラファイル/クラスを検索する * * @access public * @static */ function &getAppController($app_dir = null) { static $app_controller = array(); if (isset($app_controller[$app_dir])) { return $app_controller[$app_dir]; } else { if ($app_dir === null) { return Ethna::raiseError('$app_dir not specified.'); } } $ini_file = null; while (is_dir($app_dir)) { if (is_file("{$app_dir}/.ethna")) { $ini_file = "{$app_dir}/.ethna"; break; } $app_dir = dirname($app_dir); if (Ethna_Util::isRootDir($app_dir)) { break; } } if ($ini_file === null) { return Ethna::raiseError('no .ethna file found'); } $macro = parse_ini_file($ini_file); if (isset($macro['controller_file']) == false || isset($macro['controller_class']) == false) { return Ethna::raiseError('invalid .ethna file'); } $file = $macro['controller_file']; $class = $macro['controller_class']; $controller_file = "{$app_dir}/{$file}"; if (is_file($controller_file) == false) { return Ethna::raiseError("no such file {$controller_file}"); } include_once $controller_file; if (class_exists($class) == false) { return Ethna::raiseError("no such class {$class}"); } $global_controller =& $GLOBALS['_Ethna_controller']; $app_controller[$app_dir] =& new $class(GATEWAY_CLI); $GLOBALS['_Ethna_controller'] =& $global_controller; Ethna::clearErrorCallback(); Ethna::setErrorCallback(array('Ethna_Handle', 'handleError')); return $app_controller[$app_dir]; }
function setUp() { $GLOBALS['_dummy_error_callback_global'] = NULL; $this->dummy_error_value_class = NULL; Ethna::clearErrorCallback(); }