setResponse($response); $controllerName = $request->getControllerName(); if (! $controllerName) { parent::dispatch($request, $response); return; } $controllerName = StringHelper::cname($controllerName, '-') . 'Controller'; $moduleName = $request->getModuleName(); if ($moduleName === null || $moduleName === $this->_defaultModule) { $controllerClass = 'Icinga\\' . self::CONTROLLER_NAMESPACE . '\\' . $controllerName; } else { $controllerClass = 'Icinga\\Module\\' . ucfirst($moduleName) . '\\' . self::CONTROLLER_NAMESPACE . '\\' . $controllerName; } if (! class_exists($controllerClass)) { parent::dispatch($request, $response); return; } $controller = new $controllerClass($request, $response, $this->getParams()); if (! $controller instanceof Zend_Controller_Action && ! $controller instanceof Zend_Controller_Action_Interface ) { throw new Zend_Controller_Dispatcher_Exception( 'Controller "' . $controllerClass . '" is not an instance of Zend_Controller_Action_Interface' ); } $action = $this->getActionMethod($request); $request->setDispatched(true); // Buffer output by default $disableOb = $this->getParam('disableOutputBuffering'); $obLevel = ob_get_level(); if (empty($disableOb)) { ob_start(); } try { $controller->dispatch($action); } catch (Exception $e) { // Clean output buffer on error $curObLevel = ob_get_level(); if ($curObLevel > $obLevel) { do { ob_get_clean(); $curObLevel = ob_get_level(); } while ($curObLevel > $obLevel); } throw $e; } if (empty($disableOb)) { $content = ob_get_clean(); $response->appendBody($content); } } }