Skip to content

Commit

Permalink
Add accessor method View::$layoutPath.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Jun 18, 2015
1 parent 18766a6 commit 28f459e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Controller/Component/RequestHandlerComponent.php
Expand Up @@ -568,7 +568,7 @@ public function renderAs(Controller $controller, $type, array $options = [])
}

$this->_renderType = $type;
$controller->getView()->layoutPath = $type;
$controller->getView()->layoutPath($type);
}

$response = $this->response;
Expand Down
2 changes: 1 addition & 1 deletion src/Error/ExceptionRenderer.php
Expand Up @@ -331,7 +331,7 @@ protected function _outputMessageSafe($template)
{
$this->controller->helpers = ['Form', 'Html'];
$view = $this->controller->createView();
$view->layoutPath = null;
$view->layoutPath('');
$view->viewPath('Error');

$this->controller->response->body($view->render($template, 'error'));
Expand Down
17 changes: 16 additions & 1 deletion src/View/View.php
Expand Up @@ -351,6 +351,21 @@ public function viewPath($path = null)
$this->viewPath = $path;
}

/**
* Get/set path for layout files.
*
* @param string $path Path for layout files. If null returns current path.
* @return string|void
*/
public function layoutPath($path = null)
{
if ($path === null) {
return $this->layoutPath;
}

$this->layoutPath = $path;
}

/**
* Renders a piece of PHP with provided parameters and returns HTML, XML, or any other string.
*
Expand Down Expand Up @@ -992,7 +1007,7 @@ protected function _getLayoutFileName($name = null)
}
$subDir = null;

if ($this->layoutPath !== null) {
if ($this->layoutPath) {
$subDir = $this->layoutPath . DS;
}
list($plugin, $name) = $this->pluginSplit($name);
Expand Down

0 comments on commit 28f459e

Please sign in to comment.