本文整理汇总了PHP中Zend_Controller_Response_Http::append方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Response_Http::append方法的具体用法?PHP Zend_Controller_Response_Http::append怎么用?PHP Zend_Controller_Response_Http::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Response_Http
的用法示例。
在下文中一共展示了Zend_Controller_Response_Http::append方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stage2
/**
* STAGE 2: Find the right action and execute it.
*/
public static function stage2($frontController)
{
/////////////////////////////
// ==> SECTION: mvc <==
$frontController->returnResponse(true);
// return the response (do not echo it to the browser)
// show exceptions immediately, instead of adding to the response
$frontController->throwExceptions(true);
// without this no exceptions are thrown
$config = self::$registry['config'];
require 'lib/Controller/Action.php';
// ZFDemo's customized Zend_Controller_Action
require_once 'Zend/Controller/Request/Http.php';
$request = new Zend_Controller_Request_Http();
require_once 'Zend/Controller/Response/Http.php';
$response = new Zend_Controller_Response_Http();
$response->append('body', '');
// initialize a body segment
// safety shutoff, in case controllers are stuck in loop, each calling the other
$maxDispatches = isset($config->maxDispatches) ? $config->maxDispatches : 5;
// rerouteTo will designate either an error code (mapped to error controller), or module/controller/action
$rerouteTo = $didRerouteTo = $rerouteToReason = null;
if (isset(self::$registry['testDbFailed']) && substr($request->getRequestUri(), -12) !== '/index/reset') {
// during STAGE 1, sanity check of the DB connection/tables failed, so reroute to informative page
$rerouteTo = self::reroute($request, self::$registry['config']->testDbFailed, $frontController);
}
do {
if ($rerouteTo) {
// if a reroute was requested, process it now
$didRerouteTo = self::reroute($request, $rerouteTo, $frontController, $rerouteToReason);
$rerouteToReason = $rerouteTo = null;
}
/////////////////////////////
// ==> SECTION: mvc <==
try {
// "Run" the configured MVC "program" - the calculated action of the selected controller
$frontController->dispatch($request, $response);
} catch (ZFDemo_Exception_Reroute $exception) {
// action controller requested a reroute form of internal redirection
$rerouteTo = $exception->getRouteTo();
$suggestedHttpCode = $exception->getHttpCode();
$rerouteToReason = 'Reroute: ' . $exception->getMessage() . '; ' . $exception->responseCodeAsText();
} catch (Exception $exception) {
// don't allow *any* exceptions to end this script, without handling them properly
if (!$config->analyzeDispatchErrors) {
// we are not analyzing the errors, so
self::doExit(404, $exception);
// log event and exit
}
/////////////////////////////
// ==> SECTION: except <==
list($suggestedHttpCode, $rerouteToReason) = self::analyzeError($exception, $request, $response);
// if we have not already tried dispatching this controller code
if ($didRerouteTo['code'] !== $suggestedHttpCode) {
$rerouteTo = $suggestedHttpCode;
#$rerouteToReason = $exception->getMessage();
} else {
// Already tried to dispatch the selected error controller, so now fail hard.
ZFDemo_Log::logDispatchFailure($didRerouteTo);
if (self::isLocalRequest() && $config->view->showLog) {
echo ZFDemo_Log::get($exception);
}
// Reader excercise: make output "pretty" when dispatching error controller fails
self::doExit($suggestedHttpCode, $exception, is_int($didRerouteTo['code']) && $didRerouteTo['code'] > 400 ? _('An additional error occurred while trying to use the error action controller.') : '');
}
}
} while ($rerouteTo && --$maxDispatches);
// now loop to dispatch the alternative controller (if any)
if ($maxDispatches === 0) {
ZFDemo_Log::log(_('ERROR Too many reroutes. Controllers stuck in loop?') . $request->getRequestUri());
}
/////////////////////////////
// ==> SECTION: except <==
if (isset($suggestedHttpCode) && $suggestedHttpCode != 200) {
// something unusual happened during dispatch, like a 404 or 500 error
self::setHeaderStatus($suggestedHttpCode);
}
/////////////////////////////
// ==> SECTION: mvc <==
$baseUrl = $request->getBaseUrl();
// save for use in header/footer/site templates
if (false === strpos($baseUrl, '/index.php')) {
$baseUrl .= '/index.php';
}
self::$view->baseUrl = $baseUrl;
if (ZFDemo::isLocalRequest()) {
// Since this is only added for local network requests, this code
// may remain in production applications to aid in ongoing development.
// Add some helpful debugging information for inserting into HTML comments:
self::$view->controller = $request->getControllerName();
self::$view->module = $request->getModuleName();
self::$view->action = $request->getActionName();
}
return $response;
}