Skip to content

Commit

Permalink
Move the *creation* of the view back into the constructor, but keep t…
Browse files Browse the repository at this point in the history
…he layout

changes intact.
  • Loading branch information
Mat Gadd committed Sep 19, 2013
1 parent 213e31f commit 6071127
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions Mail.php
Expand Up @@ -82,6 +82,10 @@ protected function _calculateTemplatePath($template)
public function __construct($charset = 'iso-8859-1')
{
parent::__construct($charset);

// We need the view ivar immediately, since users of this class may need
// to set view variables on it before calling the setBody* methods.
$this->_createView();
}

/**
Expand Down Expand Up @@ -124,23 +128,29 @@ public function setBodyHtmlFromTemplate($template, $charset = null,
}

/**
* Set up the layout and view ready for rendering.
* Create the view, and store its layout state.
*
* @return void
*/
protected function _setUpLayout()
protected function _createView()
{
if (! $this->view) {
if (! \Zend_Registry::isRegistered('Ztal_View')) {
throw new \Exception('No available Ztal View');
}
if (! \Zend_Registry::isRegistered('Ztal_View')) {
throw new \Exception('No available Ztal View');
}

$this->view = clone \Zend_Registry::get('Ztal_View');
$this->view = clone \Zend_Registry::get('Ztal_View');

// Remember the state of layout so we can reinstate it after rendering.
$this->_layoutWasEnabled = $this->view->layout()->isEnabled();
}
// Remember the state of layout so we can reinstate it after rendering.
$this->_layoutWasEnabled = $this->view->layout()->isEnabled();
}

/**
* Set up the layout and view ready for rendering.
*
* @return void
*/
protected function _setUpLayout()
{
$this->view->layout()->disableLayout();
$this->view->setCompressWhitespace(true);
}
Expand Down

0 comments on commit 6071127

Please sign in to comment.