Skip to content

Commit

Permalink
Merge branch 'hotfix-relocate-template-dir'
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Lockhart committed Dec 24, 2011
2 parents 60e6098 + 9381b17 commit 3f076b1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 23 deletions.
14 changes: 8 additions & 6 deletions Slim/Slim.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ public function __construct( $userSettings = array() ) {
$this->setName('default');
}

// Setting template path
$templatesPath = $this->config('templates.path');
//Legacy support
if ( is_null($templatesPath) ) {
$templatesPath = $this->config('templates_dir');
}
$this->view->setTemplatesDirectory($templatesPath);

//Set global Error handler after Slim app instantiated
set_error_handler(array('Slim', 'handleErrors'));
}
Expand Down Expand Up @@ -595,12 +603,6 @@ public function view( $viewClass = null ) {
* @return void
*/
public function render( $template, $data = array(), $status = null ) {
$templatesPath = $this->config('templates.path');
//Legacy support
if ( is_null($templatesPath) ) {
$templatesPath = $this->config('templates_dir');
}
$this->view->setTemplatesDirectory($templatesPath);
if ( !is_null($status) ) {
$this->response->status($status);
}
Expand Down
3 changes: 0 additions & 3 deletions Slim/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@ public function getTemplatesDirectory() {
* @throws RuntimeException If directory is not a directory or does not exist
*/
public function setTemplatesDirectory( $dir ) {
if ( !is_dir($dir) ) {
throw new RuntimeException('Cannot set View templates directory to: ' . $dir . '. Directory does not exist.');
}
$this->templatesDirectory = rtrim($dir, '/');
}

Expand Down
14 changes: 0 additions & 14 deletions tests/ViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,6 @@ public function testTemplatesDirectoryWithTrailingSlash() {
$this->assertEquals(dirname(__FILE__) . '/templates', $this->view->getTemplatesDirectory());
}

/**
* Test View throws Exception if templates directory does not exist
*
* Pre-conditions:
* View templates directory is set to a non-existent directory
*
* Post-conditions:
* A RuntimeException is thrown
*/
public function testExceptionForInvalidTemplatesDirectory() {
$this->setExpectedException('RuntimeException');
$this->view->setTemplatesDirectory('./foo');
}

/**
* Test View renders template
*
Expand Down

0 comments on commit 3f076b1

Please sign in to comment.