本文整理汇总了PHP中Zend_Controller_Front::dispatch方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Front::dispatch方法的具体用法?PHP Zend_Controller_Front::dispatch怎么用?PHP Zend_Controller_Front::dispatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Front
的用法示例。
在下文中一共展示了Zend_Controller_Front::dispatch方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public static function run()
{
self::setRequest();
$response = new Zend_Controller_Response_Http();
$channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
$channel->setRequest(self::$_request);
$channel->setResponse($response);
// Start output buffering
ob_start();
try {
self::prepare();
Lms_Debug::debug('Request URI: ' . $_SERVER['REQUEST_URI']);
try {
self::$_frontController->dispatch(self::$_request);
} catch (Exception $e) {
Lms_Debug::crit($e->getMessage());
Lms_Debug::crit($e->getTraceAsString());
}
self::close();
} catch (Exception $e) {
Lms_Debug::crit($e->getMessage());
Lms_Debug::crit($e->getTraceAsString());
}
// Flush log data to browser
$channel->flush();
$response->sendHeaders();
}
示例2: dispatch
/**
* Dispatch the request to the dispatcher, catching any errors which bubble up
* to the surface and, in that event, display a nice template describing the error
* with debugging information. This method also controls the displaying of debug
* information in every request.
*/
public function dispatch()
{
try {
Primitus::startTimer('request');
parent::dispatch();
$request_time = number_format(Primitus::stopTimer('request'), 2);
if (defined("Primitus_DEBUG") && Primitus_DEBUG) {
$engine = new Primitus_View_Engine();
$debugInfo = Primitus::generateDebuggingData();
$engine->assign("debug", $debugInfo);
$engine->display("_main/debug.tpl");
}
} catch (Exception $e) {
$originalError = $e;
try {
$engine = new Primitus_View_Engine();
$engine->assign('error', $originalError);
$engine->display("_main/error.tpl");
} catch (Exception $e) {
$msg = "{$originalError->getMessage()} (Additionally, there was an error in the error handler: {$e->getMessage()})";
print $e->getTraceAsString();
$this->_printUglyMessage($msg);
die;
}
}
}
示例3: testCanLoadNamespacedHelper
public function testCanLoadNamespacedHelper()
{
$this->front->setControllerDirectory(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . '_files')->setResponse(new Zend_Controller_Response_Cli())->returnResponse(true);
$path = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . '_files/Helpers';
Zend_Controller_Action_HelperBroker::addPath($path, 'MyApp\\Controller\\Action\\Helper\\');
$request = new Zend_Controller_Request_Http('http://framework.zend.com/helper-broker/test-can-load-namespaced-helper/');
$response = $this->front->dispatch($request);
$this->assertEquals('MyApp\\Controller\\Action\\Helper\\NamespacedHelper', $response->getBody());
}
示例4: dispatch
/**
* Do the MVC magic... Dispatch the frontcontroller
*/
private function dispatch()
{
/**
* Do the magic
*/
try {
$this->frontController->dispatch();
} catch (Exception $e) {
if ($this->config->general->env == 'DEV') {
/**
* Custom error message if any
*/
$prms = $this->frontController->getRequest();
if ($prms->format == 'json') {
$outp = array();
$outp['CaughtException'] = get_class($e);
$outp['message'] = $e->getMessage();
$outp['code'] = $e->getCode();
$outp['file'] = $e->getFile();
$outp['line'] = $e->getLine();
$outp['trace'] = $e->getTrace();
$outp['tracehtml'] = '';
foreach ($outp['trace'] as $le) {
$outp['tracehtml'] .= "" . "<b>Line</b>: " . $le['line'] . " | " . "<b>Function</b>: " . $le['function'] . " | " . "<b>Class</b>: " . $le['class'] . " | " . "<br>";
}
print Zend_Json::encode($outp);
} else {
$outp = '';
$outp .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>APPLICATION ERROR</title>
<link href="' . $this->config->general->cdn . '/sydneyassets/styles/main.css" rel="stylesheet" type="text/css" />
</head><style>.errorbug { font-face: courrier; } th { text-align: left; background: #EEE; } </style><body>';
$outp .= '<div class="errorbug subBox"><h1>Sydney debug info</h1><ul>';
$outp .= "<li><b>Caught exception:</b> " . get_class($e) . "</li>\n";
$outp .= "<li><b>Message:</b> " . $e->getMessage() . "</li>\n";
$outp .= "<hr>\n";
$outp .= "<li><b>Code:</b> " . $e->getCode() . "</li>\n";
$outp .= "<li><b>File:</b> " . $e->getFile() . "</li>\n";
$outp .= "<li><b>Line:</b> " . $e->getLine() . "</li>\n";
$outp .= "<li><b>Trace:</b><table><tr><th class=\"errortrace\">" . implode('</td></tr><tr><th class="errortrace">', explode("\n", $e->getTraceAsString())) . "</td></tr></table>";
$outp .= '</ul></div>';
$outp .= '</body></html>';
print $this->_errologtreat($outp);
}
} else {
print "APPLICATION ERROR... Please contact the technical support";
}
}
}
示例5: testUsingFrontController
public function testUsingFrontController()
{
$controller = new Zend_Controller_Front();
$controller->setControllerDirectory(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . '_files');
$request = new Zend_Controller_Request_Http('http://framework.zend.com/empty');
$controller->setResponse(new Zend_Controller_Response_Cli());
$controller->setRouter(new Zend_Controller_Router());
$plugin = new Zend_Controller_Plugin_BrokerTest_TestPlugin();
$controller->registerPlugin($plugin);
$response = $controller->dispatch($request);
$this->assertEquals('123456', $response->getBody());
$this->assertEquals('123456', $plugin->getResponse()->getBody());
}
示例6: dispatch
/**
* Match route first, then determine dispatcher to use,
* then call parent method.
*
* @param Zend_Controller_Request_Abstract $request
*/
public function dispatch(Zend_Controller_Request_Abstract $request = null, Zend_Controller_Response_Abstract $response = null)
{
if (null !== $request) {
$this->setRequest($request);
} else {
$request = new Glitch_Controller_Request_Rest();
$this->setRequest($request);
}
$router = $this->getRouter();
$router->route($request);
if ($router->getCurrentRoute(false) != null && $router->getCurrentRoute(false) instanceof Glitch_Controller_Router_Route_Rest) {
$this->setDispatcher(Glitch_Controller_Dispatcher_Rest::cloneFromDispatcher($this->getDispatcher()));
$response = new Glitch_Controller_Response_Rest();
}
return parent::dispatch($request, $response);
}
示例7: run
public function run()
{
$this->init();
foreach ($this->config['plugins'] as $name => $config) {
include_once $name . '.php';
$plugin = new $name($config);
$this->frontController->registerPlugin($plugin);
}
try {
$__start = getmicrotime();
$this->frontController->dispatch();
za()->recordStat('za::dispatch', getmicrotime() - $__start);
} catch (Exception $e) {
// record the current _GET and _POST variables
$this->logger->err("Dispatch failed for " . current_url() . ": " . $e->getMessage() . ", get and post to follow");
$this->logger->err(print_r($_REQUEST, true));
throw $e;
}
}
示例8: testLoadFlashMessenger
public function testLoadFlashMessenger()
{
$this->markTestSkipped();
$response = $this->front->dispatch($this->request);
$this->assertEquals('Zend_Controller_Action_Helper_FlashMessenger123456', $response->getBody());
}
示例9: dispatch
/**
* Dispatches the request
*
* @param Zend_Controller_Front $frontController - The frontcontroller
* @return Zend_Controller_Response_Abstract
*/
public function dispatch(Zend_Controller_Front $frontController, Zend_Controller_Request_Abstract $request = null, Zend_Controller_Response_Abstract $response = null)
{
// Return the response
$frontController->returnResponse(true);
return $frontController->dispatch();
}
示例10: _processRequestStack
/**
* Processes the requestStack and merges their responses into $response.
*
* @param Zend_Controller_Front $front
* @param Zend_Controller_Response_Abstract $response
*
*/
protected function _processRequestStack($front, Zend_Controller_Response_Abstract $response)
{
$stack =& $this->_requestStack;
$config =& $this->_config;
$i = count($stack) - 1;
$responseStack = array();
$front->returnResponse(true);
do {
$myResponse = new Zend_Controller_Response_Http();
$nextRequest = array_pop($stack);
$nextRequest->setParam($config['indexKey'], $i);
$this->_resetHelper();
$this->_resetPlugins();
$this->_resetParams($nextRequest->getParams());
$front->setRequest($nextRequest);
$front->setResponse($myResponse);
$responseStack[] = $front->dispatch($nextRequest, $myResponse);
} while ($i--);
$front->returnResponse(false);
$bodies = array();
for ($i = 0, $len = count($responseStack); $i < $len; $i++) {
$bodies[] = $responseStack[$i]->getBody();
}
$body = implode(',', $bodies);
$response->setBody('[' . $body . ']');
}
示例11: dispatch
public function dispatch(Zend_Controller_Request_Abstract $request = null, Zend_Controller_Response_Abstract $response = null)
{
if ($request === null) {
if (PHP_SAPI == 'cli') {
$request = new Kwf_Controller_Request_Cli();
} else {
$request = new Kwf_Controller_Request_Http();
}
}
if ($response === null) {
$response = new Kwf_Controller_Response_Http();
}
try {
$ret = parent::dispatch($request, $response);
} catch (Zend_Controller_Router_Exception $e) {
if ($e->getCode() == 404) {
//fired by Zend_Controller_Router_Rewrite::route, transform into proper 404
throw new Kwf_Exception_NotFound();
} else {
throw $e;
}
}
Kwf_Benchmark::shutDown();
return $ret;
}
示例12: dispatch
public function dispatch(Zend_Controller_Request_Abstract $request = null, Zend_Controller_Response_Abstract $response = null)
{
try {
if ($this->_started) {
return parent::dispatch($request, $response);
} else {
require_once 'Sitengine/Controller/Exception.php';
$message = 'start() must be called before calling dispatch()';
throw new Sitengine_Controller_Exception($message);
}
} catch (Exception $exception) {
$message = 'A System Error has occured. Please check back later';
if ($this->_response instanceof Zend_Controller_Response_Http) {
$this->_response->setException($exception);
$this->_response->setHttpResponseCode(500);
$this->_response->sendResponse();
print $message;
return $this->_response;
} else {
print $message;
return null;
}
}
}
示例13: run
/**
* Dispatches all requests.
*
* @param Zend_Controller_Front $controller
* @return array|null Array of Response objects, or null if no tasks
*/
public function run(Zend_Controller_Front $controller)
{
$router = $controller->getRouter();
$returnResponse = $controller->returnResponse();
$responses = array();
foreach ($this->_requests as $request) {
if ($request->getControllerName()) {
// Use default router
$controller->setRouter(new Zend_Controller_Router());
}
if ($returnResponse) {
$responses[] = $controller->dispatch($request);
}
$controller->setRouter($router);
}
$this->_completed = true;
return $responses;
}