All pastes #566827 Raw Edit

Standard dispatcher

public php v1 · immutable
·published 2007-06-14 17:19 UTC
rendered paste body
    public function dispatch(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response)    {        $this->setResponse($response);        /**         * Get controller class         */        if (!$this->isDispatchable($request)) {            if (!$this->getParam('useDefaultControllerAlways')) {                require_once 'Zend/Controller/Dispatcher/Exception.php';                throw new Zend_Controller_Dispatcher_Exception('Invalid controller specified (' . $request->getControllerName() . ')');            }            $className = $this->getDefaultControllerClass($request);        } else {            $className = $this->getControllerClass($request);            if (!$className) {                $className = $this->getDefaultControllerClass($request);            }        }        /**         * Load the controller class file         */        $className = $this->loadClass($className);                /**         * Instantiate controller with request, response, and invocation          * arguments; throw exception if it's not an action controller         */        $controller = new $className($request, $this->getResponse(), $this->getParams());        if (!$controller instanceof Zend_Controller_Action) {            require_once 'Zend/Controller/Dispatcher/Exception.php';            throw new Zend_Controller_Dispatcher_Exception("Controller '$className' is not an instance of Zend_Controller_Action");        }        /**         * Retrieve the action name         */        $action = $this->getActionMethod($request);        /**         * Dispatch the method call         */        $request->setDispatched(true);        // by default, buffer output        $disableOb = $this->getParam('disableOutputBuffering');        if (empty($disableOb)) {            ob_start();        }                $eController = null;                try {            $controller->dispatch($action);        } catch (Exception $eController) {            // nothing        }                if (empty($disableOb)) {            $content = ob_get_clean();            $response->appendBody($content);        }        if ($eController && Zend_Controller_Front::getInstance()->throwExceptions()) {            throw $eController;        }                $this->_response->setException($eController);                // Destroy the page controller instance and reflection objects        $controller = null;    }