public function testLayoutAccessorsWork() { $plugin = new Zend_Layout_Controller_Plugin_Layout(); $this->assertNull($plugin->getLayout()); $layout = new Zend_Layout(array('mvcEnabled' => false)); $plugin->setlayout($layout); $this->assertSame($layout, $plugin->getLayout()); }
/** * postDispatch() plugin hook -- render layout * * @return void */ public function postDispatch(Zend_Controller_Request_Abstract $request) { $layout = $this->getLayout(); $view = $layout->getView(); if (null !== ($path = $layout->getViewScriptPath())) { if (method_exists($view, 'addScriptPath')) { $view->addScriptPath($path); } else { $view->setScriptPath($path); } } else { // TODO: throw an exception for this case } $layout->setLayoutPath($this->getThemeDirectory()); parent::postDispatch($request); }
/** * Constructor * * @param Zend_Layout $layout * @return void */ public function __construct(\Zend_Layout $layout = null) { $this->_defaultTheme = 'default'; parent::__construct($layout); }
function __construct(Zend_Layout $layout) { parent::__construct($layout); }
/** * 加载模块布局 * * @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); }