本文整理匯總了PHP中Zend_Controller_Request_Abstract::isDispatched方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Controller_Request_Abstract::isDispatched方法的具體用法?PHP Zend_Controller_Request_Abstract::isDispatched怎麽用?PHP Zend_Controller_Request_Abstract::isDispatched使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend_Controller_Request_Abstract
的用法示例。
在下文中一共展示了Zend_Controller_Request_Abstract::isDispatched方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: action
/**
* Retrieve rendered contents of a controller action
*
* If the action results in a forward or redirect, returns empty string.
*
* @param string $action
* @param string $controller
* @param string $module Defaults to default module
* @param array $params
* @return string
*/
public function action($action, $controller, $module = null, array $params = array())
{
$this->resetObjects();
if (null === $module) {
$module = $this->defaultModule;
}
// clone the view object to prevent over-writing of view variables
$viewRendererObj = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
Zend_Controller_Action_HelperBroker::addHelper(clone $viewRendererObj);
$this->request->setParams($params)
->setModuleName($module)
->setControllerName($controller)
->setActionName($action)
->setDispatched(true);
$this->dispatcher->dispatch($this->request, $this->response);
// reset the viewRenderer object to it's original state
Zend_Controller_Action_HelperBroker::addHelper($viewRendererObj);
if (!$this->request->isDispatched()
|| $this->response->isRedirect())
{
// forwards and redirects render nothing
return '';
}
$return = $this->response->getBody();
$this->resetObjects();
return $return;
}
示例2: postDispatch
public function postDispatch(Zend_Controller_Request_Abstract $request)
{
if (!$request->isDispatched()) {
return;
}
$view = $this->_view;
if (count($view->headTitle()->getValue()) == 0) {
$view->headTitle($view->title);
}
$view->headTitle()->setSeparator(' - ');
$view->headTitle('Places to take the monsters!');
}
示例3: postDispatch
/**
* postDispatch() plugin hook -- render layout
*
* @param Zend_Controller_Request_Abstract $request
* @return void
*/
public function postDispatch(Zend_Controller_Request_Abstract $request)
{
$layout = $this->getLayout();
$helper = $this->getLayoutActionHelper();
// Return early if forward detected
if (!$request->isDispatched() || $this->getResponse()->isRedirect() || $layout->getMvcSuccessfulActionOnly() && (!empty($helper) && !$helper->isActionControllerSuccessful())) {
return;
}
// Return early if layout has been disabled
if (!$layout->isEnabled() or !$this->getLayout()->isLoaded()) {
return;
}
$response = $this->getResponse();
$content = $response->getBody(true);
$contentKey = $layout->getContentKey();
if (isset($content['default'])) {
$content[$contentKey] = $content['default'];
}
if ('default' != $contentKey) {
unset($content['default']);
}
$layout->assign($content);
$fullContent = null;
$obStartLevel = ob_get_level();
try {
$fullContent = $layout->render();
$response->setBody($fullContent);
} catch (Exception $e) {
while (ob_get_level() > $obStartLevel) {
$fullContent .= ob_get_clean();
}
$request->setParam('layoutFullContent', $fullContent);
$request->setParam('layoutContent', $layout->content);
$response->setBody(null);
if (Zend_Controller_Front::getInstance()->throwExceptions()) {
throw $e;
} else {
$this->getResponse()->setException($e);
}
}
return $this;
}
示例4: postDispatch
/**
* postDispatch() plugin hook -- check for actions in stack, and dispatch if any found
*
* @param Zend_Controller_Request_Abstract $request
* @return void
*/
public function postDispatch(Zend_Controller_Request_Abstract $request)
{
// Don't move on to next request if this is already an attempt to
// forward
if (!$request->isDispatched()) {
return;
}
$this->setRequest($request);
$stack = $this->getStack();
if (empty($stack)) {
return;
}
$next = $this->popStack();
if (!$next) {
return;
}
$this->forward($next);
}
示例5: dispatch
/**
* Dispatch an HTTP request to a controller/action.
*
* @param Zend_Controller_Request_Abstract|null $request
* @param Zend_Controller_Response_Abstract|null $response
* @return void|Zend_Controller_Response_Abstract Returns response object if returnResponse() is true
*/
public function dispatch(Zend_Controller_Request_Abstract $request = null, Zend_Controller_Response_Abstract $response = null)
{
if (!$this->getParam('noErrorHandler') && !$this->_plugins->hasPlugin('Zend_Controller_Plugin_ErrorHandler')) {
// Register with stack index of 100
#require_once 'Zend/Controller/Plugin/ErrorHandler.php';
$this->_plugins->registerPlugin(new Zend_Controller_Plugin_ErrorHandler(), 100);
}
if (!$this->getParam('noViewRenderer') && !Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer')) {
#require_once 'Zend/Controller/Action/Helper/ViewRenderer.php';
Zend_Controller_Action_HelperBroker::getStack()->offsetSet(-80, new Zend_Controller_Action_Helper_ViewRenderer());
}
/**
* Instantiate default request object (HTTP version) if none provided
*/
if (null !== $request) {
$this->setRequest($request);
} elseif (null === $request && null === ($request = $this->getRequest())) {
#require_once 'Zend/Controller/Request/Http.php';
$request = new Zend_Controller_Request_Http();
$this->setRequest($request);
}
/**
* Set base URL of request object, if available
*/
if (is_callable(array($this->_request, 'setBaseUrl'))) {
if (null !== $this->_baseUrl) {
$this->_request->setBaseUrl($this->_baseUrl);
}
}
/**
* Instantiate default response object (HTTP version) if none provided
*/
if (null !== $response) {
$this->setResponse($response);
} elseif (null === $this->_response && null === ($this->_response = $this->getResponse())) {
#require_once 'Zend/Controller/Response/Http.php';
$response = new Zend_Controller_Response_Http();
$this->setResponse($response);
}
/**
* Register request and response objects with plugin broker
*/
$this->_plugins->setRequest($this->_request)->setResponse($this->_response);
/**
* Initialize router
*/
$router = $this->getRouter();
$router->setParams($this->getParams());
/**
* Initialize dispatcher
*/
$dispatcher = $this->getDispatcher();
$dispatcher->setParams($this->getParams())->setResponse($this->_response);
// Begin dispatch
try {
/**
* Route request to controller/action, if a router is provided
*/
/**
* Notify plugins of router startup
*/
$this->_plugins->routeStartup($this->_request);
$router->route($this->_request);
/**
* Notify plugins of router completion
*/
$this->_plugins->routeShutdown($this->_request);
/**
* Notify plugins of dispatch loop startup
*/
$this->_plugins->dispatchLoopStartup($this->_request);
/**
* Attempt to dispatch the controller/action. If the $this->_request
* indicates that it needs to be dispatched, move to the next
* action in the request.
*/
do {
$this->_request->setDispatched(true);
/**
* Notify plugins of dispatch startup
*/
$this->_plugins->preDispatch($this->_request);
/**
* Skip requested action if preDispatch() has reset it
*/
if (!$this->_request->isDispatched()) {
continue;
}
/**
* Dispatch request
*/
try {
$dispatcher->dispatch($this->_request, $this->_response);
//.........這裏部分代碼省略.........
示例6: postDispatch
/**
* postDispatch() plugin hook -- check for actions in stack, and dispatch if any found
*
* @param Zend_Controller_Request_Abstract $request
* @return void
*/
public function postDispatch(Zend_Controller_Request_Abstract $request)
{
// Don't move on to next request if this is already an attempt to
// forward
if (!$request->isDispatched()) {
return;
}
if ($this->_enabled) {
$helper = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
if (!$this->_isStackInit) {
$this->_scriptPaths = $helper->view->getScriptPaths();
$this->_scriptName = $helper->getViewScript();
$this->initStack($request);
$this->_vars['content'] = $helper->view->getVars();
$this->_vars['widgets'] = array();
} else {
$vars = $helper->view->getVars();
$module = Zend_Filter::filterStatic($request->getModuleName(), $this->_options['nameFilter']);
$controller = Zend_Filter::filterStatic($request->getControllerName(), $this->_options['nameFilter']);
$action = Zend_Filter::filterStatic($request->getActionName(), $this->_options['nameFilter']);
$this->_checkStructure($module, $controller);
$this->_vars['widgets'][$module][$controller][$action] = $vars;
}
$helper->view->clearVars();
$next = $this->popStack();
if ($next) {
$this->forward($next);
}
}
}
示例7: postDispatch
/**
* postDispatch() plugin hook -- render layout
*
* @param Zend_Controller_Request_Abstract $request
* @return void
*/
public function postDispatch(Zend_Controller_Request_Abstract $request)
{
$layout = $this->getLayout();
$helper = $this->getLayoutActionHelper();
// Return early if forward detected
if (!$request->isDispatched() || $this->getResponse()->isRedirect() || $layout->getMvcSuccessfulActionOnly() && (!empty($helper) && !$helper->isActionControllerSuccessful())) {
$layout->setLayout(null);
return;
}
// Return early if layout has been disabled
if (!$layout->isEnabled()) {
return;
}
// two logic mix
$layoutName = $layout->getLayout();
if (Axis_Area::isFrontend()) {
$this->_initPages();
if (empty($layoutName)) {
$layoutName = $this->_getLayoutName();
}
$this->_initBlockAssigns();
} elseif (empty($layoutName)) {
$layoutName = 'layout';
}
$layout->setLayout($layoutName, false);
$response = $this->getResponse();
$content = $response->getBody(true);
$contentKey = $layout->getContentKey();
if (isset($content['default'])) {
$content[$contentKey] = $content['default'];
}
if ('default' != $contentKey) {
unset($content['default']);
}
$layout->assign($content);
$fullContent = null;
$obStartLevel = ob_get_level();
try {
$fullContent = $layout->render();
$response->setBody($fullContent);
} catch (Exception $e) {
while (ob_get_level() > $obStartLevel) {
$fullContent .= ob_get_clean();
}
$request->setParam('layoutFullContent', $fullContent);
$request->setParam('layoutContent', $layout->content);
$response->setBody(null);
throw $e;
}
}
示例8: isDispatchable
/**
* Returns TRUE if the Zend_Controller_Request_Abstract object can be dispatched to a controller.
* This only verifies that the Zend_Controller_Action can be dispatched and does not
* guarantee that the action will be accepted by the Zend_Controller_Action.
*
* @param Zend_Controller_Request_Abstract $action
* @return unknown
*/
public function isDispatchable(Zend_Controller_Request_Abstract $request)
{
if ($request->isDispatched()) {
return false;
}
return $this->_dispatch($request, false);
}
示例9: postDispatch
/**
* Hook 12: Called after an action is dispatched by \Zend_Controller_Dispatcher.
*
* This callback allows for proxy or filter behavior. By altering the
* request and resetting its dispatched flag (via {@link
* \Zend_Controller_Request_Abstract::setDispatched() setDispatched(false)}),
* a new action may be specified for dispatching.
*
* \Zend_Layout_Controller_Plugin_Layout uses this event to change the output
* of the $response with the rendering of the layout. As the Layout plugin
* has a priority of 99, this Escort event will take place before the layout
* is rendered, unless $this->run() was called with a stackIndex lower than zero.
*
* Previous hook: controllerAfterAction()
* Actions since: ob_get_clean(); $response->appendBody()
* Actions after: while (! Request->isDispatched()) or back to Hook 8 preDispatch()
* Next hook: dispatchLoopShutdown()
*
* @param \Zend_Controller_Request_Abstract $request
* @return void
*/
public function postDispatch(\Zend_Controller_Request_Abstract $request)
{
if ($request->isDispatched()) {
$response = \Zend_Controller_Front::getInstance()->getResponse();
$response->setHeader('X-UA-Compatible', 'IE=edge,chrome=1', true);
if ($this->project->offsetExists('x-frame')) {
$response->setHeader('X-Frame-Options', $this->project->offsetGet('x-frame'), true);
}
// Only when we need to render the layout, we run the layout prepare
if (\Zend_Controller_Action_HelperBroker::hasHelper('layout') && \Zend_Controller_Action_HelperBroker::getExistingHelper('layout')->isEnabled()) {
// Per project layout preparation
if (isset($this->project->layoutPrepare)) {
foreach ($this->project->layoutPrepare as $prepare => $type) {
if ($type) {
$function = '_layout' . ucfirst($prepare);
if (isset($this->project->layoutPrepareArgs, $this->project->layoutPrepareArgs[$prepare])) {
$args = $this->project->layoutPrepareArgs[$prepare];
} else {
$args = array();
}
$result = $this->{$function}($args);
// When a result is returned, add it to the view,
// according to the type method
if (null !== $result) {
if (is_numeric($type)) {
$this->view->{$prepare} = $result;
} else {
if (!isset($this->view->{$type})) {
$this->view->{$type} = new \MUtil_Html_Sequence();
}
$sequence = $this->view->{$type};
$sequence[$prepare] = $result;
}
}
}
}
}
}
// For AJAX calls we sometimes need to add JQuery onload scripts since otherwise they won't get rendered:
// We expect JQuery to be loaded in the master page, since the call is probably made using JQuery
if ($request instanceof \Zend_Controller_Request_Http && $request->isXmlHttpRequest()) {
\MUtil_JQuery::enableView($this->view);
$scripts = $this->view->jQuery()->getOnLoadActions();
$content = '';
foreach ($scripts as $script) {
$content .= "<script type='text/javascript'>{$script}</script>\n";
}
$content .= $this->view->inlineScript();
// Now cleanup the rendered content (just to make sure)
$this->view->jQuery()->clearOnLoadActions();
$this->view->inlineScript()->exchangeArray(array());
if (!empty($content)) {
$response->appendBody($content);
}
}
}
}
示例10: postDispatch
/**
* 加載模塊布局
*
* @see Zend_Layout_Controller_Plugin_Layout::postDispatch()
* @return void
*/
public function postDispatch(Zend_Controller_Request_Abstract $request)
{
if ($this->_layout->getMvcSuccessfulActionOnly() && (!empty($this->_layoutActionHelper) && !$this->_layoutActionHelper->isActionControllerSuccessful()) || !$this->_layout->isEnabled() || !$request->isDispatched() || $this->_response->isRedirect()) {
return;
}
if ($this->hasModuleLayout($module = $request->getModuleName())) {
$content = $this->_response->getBody(true);
if (isset($content['default'])) {
$content[$this->_layout->getContentKey()] = $content['default'];
}
if ('default' != $this->_layout->getContentKey()) {
unset($content['default']);
}
$this->_layout->assign($content);
try {
$this->_response->setBody($this->_layout->render(self::$_moduleLayout[$module]));
} catch (Exception $e) {
$this->_response->setBody(null);
throw $e;
}
}
parent::postDispatch($request);
}