public function run() { //$mem = ((memory_get_peak_usage(true) / 1024) / 1024) . 'Mb'; //var_dump($mem); static $run; // there will be only one if (true === $run) { return; } $request = Hayate_Request::getInstance(); $dispatcher = Hayate_Dispatcher::getInstance(); Hayate_Event::run('hayate.pre_dispatch', array($dispatcher)); do { $request->dispatched(true); $dispatcher->dispatch(); if ($request->dispatched()) { Hayate_Event::run('hayate.post_dispatch', array($dispatcher, $request)); } } while (false === $request->dispatched()); Hayate_Event::run('hayate.send_headers'); Hayate_Event::run('hayate.render'); $run = true; Hayate_Event::run('hayate.shutdown'); //$mem = ((memory_get_peak_usage(true) / 1024) / 1024) . 'Mb'; //var_dump($mem); }
public function exceptionDispatch(Exception $ex) { try { if (Hayate_Event::run('hayate.exception', array($this, $ex))) { return; } // try to dispatch to the current module error.php controller $module = $this->module(); $filepath = $this->modulesPath . $module . '/controllers/error.php'; // if the error controller does not exists in the current module // look in the default module if (!is_file($filepath)) { $module = Hayate_Config::getInstance()->get('default_module', 'default'); $filepath = $this->modulesPath . $module . '/controllers/error.php'; } if (is_file($filepath)) { require_once $filepath; $classname = ucfirst($module) . '_ErrorController'; $rfc = new ReflectionClass($classname); if ($rfc->isSubclassOf('Hayate_Controller') && $rfc->isInstantiable()) { $controller = $rfc->newInstance(); $action = $rfc->hasMethod('index') ? $rfc->getMethod('index') : $rfc->getMethod('__call'); if ($action->isPublic()) { $action->invokeArgs($controller, array($ex)); } } } else { $display_errors = Hayate_Config::getInstance()->get('display_errors', false); if ($display_errors && $this->errorReporter) { Hayate_Event::remove('hayate.send_headers'); Hayate_Event::remove('hayate.render'); $this->errorReporter->setException($ex); echo $this->errorReporter->report(); } } } catch (Exception $ex) { } }