public function testMissingViewScriptDoesDoubleRender() { Zend_Controller_Action_HelperBroker::getStack()->offsetSet(-91, new Zend_Controller_Action_Helper_ViewRenderer()); // go to the test controller for this funcitonal test $this->dispatch('/zend-layout-functional-test-test/missing-view-script'); $this->assertEquals(trim($this->response->getBody()), "[DEFAULT_LAYOUT_START]\n[DEFAULT_LAYOUT_START]\n[DEFAULT_LAYOUT_END]\n(ErrorController::errorAction output)[DEFAULT_LAYOUT_END]"); }
function _initBootstrap3() { //check theme active and get name theme $themes = Engine_Api::_()->getDbtable('themes', 'core')->fetchAll(); $activeTheme = $themes->getRowMatching('active', 1); $name_theme = $activeTheme->name; if (!in_array($name_theme, array('ynresponsive1', 'ynresponsive-event', 'ynresponsive-metro', 'ynresponsive-photo'))) { $name_theme = 'ynresponsive1'; } define('YNRESPONSIVE_ACTIVE', $name_theme); $session = new Zend_Session_Namespace('mobile'); if (!$session->mobile) { require_once APPLICATION_PATH . '/application/modules/Ynresponsive1/Engine/ContentDecoratorTitle.php'; require_once APPLICATION_PATH . '/application/modules/Ynresponsive1/Engine/BootHelper.php'; require_once APPLICATION_PATH . '/application/modules/Ynresponsive1/Engine/Pages.php'; require_once APPLICATION_PATH . '/application/modules/Ynresponsive1/Engine/Container.php'; $view = Zend_Registry::get('Zend_View'); if (Engine_Api::_()->ynresponsive1()->isMobile()) { $mode = Engine_Api::_()->getApi('settings', 'core')->getSetting('form.mode', 0); if ($mode) { $view->addHelperPath(APPLICATION_PATH . '/application/modules/Ynresponsive1/View/Helper/YNHtml5', 'Ynresponsive1_View_Helper_YNHtml5'); } else { $view->addHelperPath(APPLICATION_PATH . '/application/modules/Ynresponsive1/View/Helper/YNTinyMce', 'Ynresponsive1_View_Helper_YNTinyMce'); } } else { $view->addHelperPath(APPLICATION_PATH . '/application/modules/Ynresponsive1/View/Helper/YNTinyMce', 'Ynresponsive1_View_Helper_YNTinyMce'); } $view->addHelperPath(APPLICATION_PATH . '/application/modules/Ynresponsive1/View/Helper', 'Ynresponsive1_View_Helper_FormYnResCalendarSimple'); // Setup and register viewRenderer // @todo we may not need to override zend's if (Zend_Registry::isRegistered("Engine_Content")) { // Save to registry $content = Zend_Registry::get('Engine_Content'); $contentTable = new Ynresponsive1_Model_DbTable_Pages(); $content->setStorage($contentTable); } $helper = new Ynresponsive1_BootHelper(); Zend_Controller_Action_HelperBroker::getStack()->offsetSet(-79, $helper); } }
/** * Initialize action helper * * @return void */ protected function _initHelper() { $helperClass = $this->getHelperClass(); require_once 'Zend/Controller/Action/HelperBroker.php'; if (!Zend_Controller_Action_HelperBroker::hasHelper('layout')) { require_once 'Zend/Loader.php'; Zend_Loader::loadClass($helperClass); Zend_Controller_Action_HelperBroker::getStack()->offsetSet(-90, new $helperClass($this)); } }
/** * 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); } catch (Exception $e) { if ($this->throwExceptions()) { throw $e; } $this->_response->setException($e); } /** * Notify plugins of dispatch completion */ $this->_plugins->postDispatch($this->_request); } while (!$this->_request->isDispatched()); } catch (Exception $e) { if ($this->throwExceptions()) { throw $e; } $this->_response->setException($e); } /** * Notify plugins of dispatch loop completion */ try { $this->_plugins->dispatchLoopShutdown(); } catch (Exception $e) { if ($this->throwExceptions()) { throw $e; } $this->_response->setException($e); } if ($this->returnResponse()) { return $this->_response; } $this->_response->sendResponse(); }
/** * Resets all helpers to the helpers found in $_helperList. */ protected function _resetHelper() { Zend_Controller_Action_HelperBroker::resetHelpers(); foreach ($this->_helperList as $key => $helper) { Zend_Controller_Action_HelperBroker::getStack()->offsetSet($key, clone $helper); } }
protected function _initView() { // Create view $view = new Zend_View(); // Set encoding (@todo maybe use configuration?) $view->setEncoding('utf-8'); $view->addScriptPath(APPLICATION_PATH); // Setup and register viewRenderer // @todo we may not need to override zend's $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view); $viewRenderer->setViewSuffix('phtml'); Zend_Controller_Action_HelperBroker::getStack()->offsetSet(-80, $viewRenderer); // Add default helper paths $view->addHelperPath('Khcn/View/Helper/', 'Khcn_View_Helper_'); $this->initViewHelperPath(); // Set doctype $doctypeHelper = new Zend_View_Helper_Doctype(); $doctypeHelper->doctype('XHTML1_STRICT'); // Add to local container and registry Zend_Registry::set('Zend_View', $view); return $view; }
/** * Initialize action helper * * @return void */ protected function _initHelper() { $helperClass = $this->getHelperClass(); if (!Zend_Controller_Action_HelperBroker::hasHelper('layout')) { if (!class_exists($helperClass)) { Zend_Loader::loadClass($helperClass); } Zend_Controller_Action_HelperBroker::getStack()->offsetSet(-90, new $helperClass($this)); } }
protected function _initContent() { $content = Engine_Content::getInstance(); // Set storage $contentTable = Engine_Api::_()->getDbtable('pages', 'core'); $content->setStorage($contentTable); // Load content helper $contentRenderer = new Engine_Content_Controller_Action_Helper_Content(); $contentRenderer->setContent($content); Zend_Controller_Action_HelperBroker::getStack()->offsetSet(-85, $contentRenderer); // Set cache object if (isset($this->getContainer()->cache)) { $content->setCache($this->getContainer()->cache); } // Set translator if (isset($this->getContainer()->translate)) { $content->setTranslator($this->getContainer()->translate); } // Save to registry Zend_Registry::set('Engine_Content', $content); return $content; }
/** * getStack * * Return the helper action stack * * @return \Zend_Controller_Action_HelperBroker_PriorityStack */ public function getStack() { return \Zend_Controller_Action_HelperBroker::getStack(); }