Skip to content

Commit

Permalink
Merge remote-tracking branch 'weierophinney/hotfix/view-strategy-conf…
Browse files Browse the repository at this point in the history
…ig-names'
  • Loading branch information
akrabat committed Feb 28, 2012
2 parents dc47c92 + 4b1cbab commit e7ef930
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 38 deletions.
10 changes: 5 additions & 5 deletions library/Zend/Mvc/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ protected function setupLocator(AppContext $application)
),
),
'Zend\Mvc\View\DefaultRenderingStrategy' => array(
'setBaseTemplate' => array(
'baseTemplate' => array(
'setLayoutTemplate' => array(
'layoutTemplate' => array(
'required' => false,
'type' => false,
),
Expand All @@ -126,8 +126,8 @@ protected function setupLocator(AppContext $application)
'type' => false,
),
),
'setErrorTemplate' => array(
'template' => array(
'setExceptionTemplate' => array(
'exceptionTemplate' => array(
'required' => false,
'type' => false,
),
Expand Down Expand Up @@ -272,7 +272,7 @@ protected function setupView($application)
// Inject MVC Event with view model
$mvcEvent = $application->getMvcEvent();
$viewModel = $mvcEvent->getViewModel();
$viewModel->setTemplate($defaultViewStrategy->getBaseTemplate());
$viewModel->setTemplate($defaultViewStrategy->getLayoutTemplate());

// Inject MVC Event view model as root view model
$renderer = $phpRendererStrategy->getRenderer();
Expand Down
20 changes: 9 additions & 11 deletions library/Zend/Mvc/View/DefaultRenderingStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@ class DefaultRenderingStrategy implements ListenerAggregate
protected $listeners = array();

/**
* Base template - template used in root ViewModel of MVC event.
* Layout template - template used in root ViewModel of MVC event.
*
* This is typically a layout template.
*
* @var string
*/
protected $baseTemplate = 'layout';
protected $layoutTemplate = 'layout';

/**
* @var View
Expand Down Expand Up @@ -95,25 +93,25 @@ public function detach(EventCollection $events)
}

/**
* Set base template value
* Set layout template value
*
* @param string $baseTemplate
* @param string $layoutTemplate
* @return DefaultRenderingStrategy
*/
public function setBaseTemplate($baseTemplate)
public function setLayoutTemplate($layoutTemplate)
{
$this->baseTemplate = (string) $baseTemplate;
$this->layoutTemplate = (string) $layoutTemplate;
return $this;
}

/**
* Get base template value
* Get layout template value
*
* @return string
*/
public function getBaseTemplate()
public function getLayoutTemplate()
{
return $this->baseTemplate;
return $this->layoutTemplate;
}

/**
Expand Down
22 changes: 11 additions & 11 deletions library/Zend/Mvc/View/ExceptionStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ class ExceptionStrategy implements ListenerAggregate
protected $displayExceptions = false;

/**
* Name of error template
* Name of exception template
* @var string
*/
protected $errorTemplate = 'error';
protected $exceptionTemplate = 'error';

/**
* @var \Zend\Stdlib\CallbackHandler[]
Expand Down Expand Up @@ -104,29 +104,29 @@ public function displayExceptions()
}

/**
* Set the error template
* Set the exception template
*
* @param string $template
* @param string $exceptionTemplate
* @return ExceptionStrategy
*/
public function setErrorTemplate($template)
public function setExceptionTemplate($exceptionTemplate)
{
$this->errorTemplate = (string) $template;
$this->exceptionTemplate = (string) $exceptionTemplate;
return $this;
}

/**
* Retrieve the error template
* Retrieve the exception template
*
* @return string
*/
public function getErrorTemplate()
public function getExceptionTemplate()
{
return $this->errorTemplate;
return $this->exceptionTemplate;
}

/**
* Create an error view model, and set the HTTP status code
* Create an exception view model, and set the HTTP status code
*
* @todo dispatch.error does not halt dispatch unless a response is
* returned. As such, we likely need to trigger rendering as a low
Expand Down Expand Up @@ -163,7 +163,7 @@ public function prepareExceptionViewModel(MvcEvent $e)
'exception' => $e->getParam('exception'),
'display_exceptions' => $this->displayExceptions(),
));
$model->setTemplate($this->getErrorTemplate());
$model->setTemplate($this->getExceptionTemplate());
$e->setResult($model);

$response = $e->getResponse();
Expand Down
10 changes: 5 additions & 5 deletions tests/Zend/Mvc/View/DefaultRendereringStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ public function testWillRenderAlternateStrategyWhenSelected()
$expected = sprintf('content (%s): %s', json_encode(array('template' => 'content')), json_encode(array('foo' => 'bar')));
}

public function testBaseTemplateIsLayoutByDefault()
public function testLayoutTemplateIsLayoutByDefault()
{
$this->assertEquals('layout', $this->strategy->getBaseTemplate());
$this->assertEquals('layout', $this->strategy->getLayoutTemplate());
}

public function testBaseTemplateIsMutable()
public function testLayoutTemplateIsMutable()
{
$this->strategy->setBaseTemplate('alternate/layout');
$this->assertEquals('alternate/layout', $this->strategy->getBaseTemplate());
$this->strategy->setLayoutTemplate('alternate/layout');
$this->assertEquals('alternate/layout', $this->strategy->getLayoutTemplate());
}

public function testBypassesRenderingIfResultIsAResponse()
Expand Down
12 changes: 6 additions & 6 deletions tests/Zend/Mvc/View/ExceptionStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ public function testDisplayExceptionsFlagIsMutable()
$this->assertTrue($this->strategy->displayExceptions());
}

public function testErrorTemplateHasASaneDefault()
public function testExceptionTemplateHasASaneDefault()
{
$this->assertEquals('error', $this->strategy->getErrorTemplate());
$this->assertEquals('error', $this->strategy->getExceptionTemplate());
}

public function testErrorTemplateIsMutable()
public function testExceptionTemplateIsMutable()
{
$this->strategy->setErrorTemplate('pages/error');
$this->assertEquals('pages/error', $this->strategy->getErrorTemplate());
$this->strategy->setExceptionTemplate('pages/error');
$this->assertEquals('pages/error', $this->strategy->getExceptionTemplate());
}

public function test404ApplicationErrorsResultInNoOperations()
Expand Down Expand Up @@ -100,7 +100,7 @@ public function testCatchesApplicationExceptions()

$model = $event->getResult();
$this->assertInstanceOf('Zend\View\Model\ViewModel', $model);
$this->assertEquals($this->strategy->getErrorTemplate(), $model->getTemplate());
$this->assertEquals($this->strategy->getExceptionTemplate(), $model->getTemplate());

$variables = $model->getVariables();
$this->assertArrayHasKey('message', $variables);
Expand Down

0 comments on commit e7ef930

Please sign in to comment.