/** * メソッドの必須項目をチェック * * 連想配列で受け取った値に必要なキーがあるかチェックします。 * 問題ががればBEAR_Exceptionが投げられます。 * * @param array $values 配列 * * @return void * @throws BEAR_Annotation_Exception */ public function required(array $values) { $match = array(); $result = preg_match_all("/@required\\s+(\\w+)/is", $this->_config['doc']['method'], $match); if ($result !== false) { // メソッド優先 try { BEAR_Util::required($match[1], $values); } catch (Exception $e) { $info = array('RO' => $this->_config['ref']['method']->class . '::' . $this->_config['ref']['method']->name, 'required' => $match[1], 'values' => $values, 'doc' => $this->_config['doc']['method']); $required = implode($match[1], ','); $msg = "@required item[{$required}] is missing."; throw $this->_exception($msg, array('code' => BEAR::CODE_BAD_REQUEST, 'info' => $info)); } } }
/** * アプリケーション実行 * * @param int $mode 動作モード * * @return void */ public static function init($mode = 1) { $app = BEAR::loadConfig(_BEAR_APP_HOME . '/App/app.yml'); switch ($mode) { case 2: case 1: //開発モード (キャッシュ有効) $app['core']['debug'] = true; $app['App_Db']['dsn']['default'] = $app['App_Db']['dsn']['slave'] = $app['App_Db']['dsn']['test']; $app['BEAR_Ro_Prototype']['__class'] = 'BEAR_Ro_Prototype_Debug'; break; case 0: default: //ライブ $app['core']['debug'] = false; break; } BEAR::init($app); // 開発モード(キャッシュクリア) if ($mode == 1) { BEAR_Util::clearAllCache(false); } }
/** * AJAX終了処理 * * ajax.logをlogフォルダに作成する * * @return void */ private function _onShutdownDebugAjax() { $ajaxLogPath = _BEAR_APP_HOME . '/logs/ajax.log'; $ajaxLog = file_exists($ajaxLogPath) ? BEAR_Util::unserialize(file_get_contents($ajaxLogPath)) : null; $log = array('page' => $this->_logs, 'uri' => $_SERVER['REQUEST_URI']); $ajaxLog[] = $log; if (count($ajaxLog) > 5) { array_shift($ajaxLog); } file_put_contents(_BEAR_APP_HOME . '/logs/ajax.log', serialize($ajaxLog)); }
/** * ログクリア * * @return void */ public function clearAll() { $this->clearCache(); $this->clearLog(); BEAR_Util::unlinkRecursive(_BEAR_APP_HOME . '/tmp/session/'); }
// デバック用画面 include _BEAR_BEAR_HOME . '/BEAR/BEAR/script/dev_info_screen.php'; // _preクエリー if (isset($_GET['_pre'])) { echo '<pre>'; } // _errorクエリー if (isset($_GET['_error'])) { ini_set('display_errors', 1); error_reporting(E_ALL); restore_error_handler(); restore_exception_handler(); return; } // exit if ($exit === true) { exit; } // デバック用キャッシュクリア if (isset($_GET['_cc'])) { BEAR_Util::clearAllCache(true); exit; } // log $log = array(); $log['BEAR'] = BEAR::VERSION; if (isset($_SERVER['REQUEST_URI'])) { $log['URI'] = $_SERVER['REQUEST_URI']; } $log['time'] = _BEAR_DATETIME; BEAR::dependency('BEAR_Log')->log('start', $log);